Hi Sean, We experienced that also with Noury and Jannik. The trick has been to extract the block in a class side method. Example: Timer>>start process := self class createProcessFor: self Timer class>>createProcessFor: aTimer ^[ aTimer value: aTimer value + 1.......] fork Now: t := Timer new start. t := nil makes the process dispear as well. ok not really beautiful but it works ;-) Cheers, Luc #Luc 2013/4/23 Igor Stasenko <siguctua@gmail.com>
On 23 April 2013 14:17, Sean P. DeNigris <sean@clipperadams.com> wrote:
Igor Stasenko wrote
you don't need finalization.. just a weak reference. something like this:
array := WeakArray with: myObject.
[[ array first notNil] whileTrue: [ ...... ]] fork.
Timer>>start
| array | array := WeakArray with: self. process := [ [ array first notNil ] whileTrue: [ interval asDelay wait. self value: self value + 1. self announcer announce: (TimerValueChanged to: self value) ] ] fork.
Timer new start. Smalltalk garbageCollect.
The process is still there...
but what you expecting? you refer to 'self' multiple times. sure thing it cannot be GC-ed, neither process will die because of plenty of references on stack. Even block closure which you creating for fork will have home context which keeps reference to 'self', e.g. receiver.
I'm attaching (to Nabble) a screenshot of #pointersTo < http://forum.world.st/file/n4683095/Screen_Shot_2013-04-23_at_8.16.01_AM.png
----- Cheers, Sean -- View this message in context: http://forum.world.st/Terminating-a-Process-when-an-object-dies-tp4683036p46... Sent from the Pharo Smalltalk Users mailing list archive at Nabble.com.
-- Best regards, Igor Stasenko.