releaseActionMap during finalization?

Ned Konz ned at bike-nomad.com
Sun Mar 2 18:40:50 UTC 2003


On Sunday 02 March 2003 09:39 am, Christian Hofer wrote:

> It is also there that I read that you have to remove all registered
> event handlers (using Object's event mechanism) yourself - quite
> painful for someone used to garbage collection. And indeed I found
> out I generated lots of entries in the EventManager's ActionMap
> (though I confess I hardly understand how it works).

Those entries should be weak, and should not require manual removal.

> I thought about two ways to handle this problem:
>
> 1. I added a finalize-method to my model:
> ~   CounterModel>>finalize
> ~     super finalize.
> ~     self releaseActionMap
>
> As of now I could not see any effects. Is the code wrong or is it
> just because the garbage collector has not started its work yet?

Try to force a GC and see if it makes a difference.

> 2. Maybe it is a viable alternative that my model registers its
> interest in the moment of destruction of its morph. But to subsribe
> for a further event does not seem to be a very elegant solution in
> my eyes.
>
> Can anybody help me out?

If you have a recent 3.4 (that is, after the event system fixes we 
last put in), then you should be able to ignore all of this 
finalization behavior.

The event registrations are in the form of WeakMessageSends, and the 
action maps themselves are held in a WeakIdentityKeyDictionary.

-- 
Ned Konz
http://bike-nomad.com
GPG key ID: BEEA7EFE



More information about the Squeak-dev mailing list