[squeak-dev] finalizing processes?

Yoshiki Ohshima yoshiki at vpri.org
Wed Nov 30 23:32:34 UTC 2011


  Hello,

I have trouble terminating some processes I make.  More specifically,
I'm trying to terminate some processes when the their associated
"owner" object is garbage collected.  The problem seems that these
processes hold back pointers to my owner object via outerContext of
the closures so the owner object does not get garbage collected when
nobody else is pointing to it.

Attached is my test case.  After filing in this to a trunk image,
evaluate:

	k := KEventStream new.
	KEventStream beTimer: k with: 100.

in a workspace.  You'll see a little counter going on the left edge of
screen.  What I want to do is to stop the counter by evaluating:

	k := nil. Smalltalk garbageCollect.

but the processes hold onto the closure, which in turn holds onto the
context for executing #beTimer:with:, and that context holds onto 'k',
or 'anObject'.

I thought that closure could just be detached from the outer context but
it is not the case here.  Why?

Thank you!

-- Yoshiki

-------------- next part --------------
A non-text attachment was scrubbed...
Name: KEventStream.st
Type: application/octet-stream
Size: 1555 bytes
Desc: not available
Url : http://lists.squeakfoundation.org/pipermail/squeak-dev/attachments/20111130/8519d26d/KEventStream.obj
-------------- next part --------------



More information about the Squeak-dev mailing list