[squeak-dev] WeakArray and use of weak collections.

Philippe Marschall philippe.marschall at gmail.com
Mon Feb 25 19:23:29 UTC 2008


2008/2/25, Gary Chambers <gazzaguru2 at btinternet.com>:
> Today I've had "fun" trying to fix a problem with our software (that uses
>  many processes running at various priorities). Due to the use of a
>  WeakIdentitykeyDictionary I was running into problems witht the dictionary
>  having multiple identical keys... not pleasant, especially when it gets to
>  around 27000 entries (should be 20).
>
>  I have traced the problem to the fact that finalisation is not thread-safe
>  with respect to access of said dictionary. As a fix I have implemented a
>  #critical: method on the WeakArray class that evaluates the given block with
>  a #critical: call on the FinalizationLock of WeakArray.
>
>  Access to the weak dictionary is now wrapped with a WeakArray critical:
>  [...] and the problems have, thankfully, disappeared.
>
>  I can post a Mantis entry for this if you all think it is appropriate. Just
>  wondering how many other places in existing Squeak code might trip up on
>  this.

In general weak array finalization will kill you sooner or later
anyway. One of the big performance improvements in Seaside is removing
WeakIdentitykeyDictionarys. We could simply not live with the fact
that at one point the image will block for 20 minutes and hog the CPU.
We now use more memory because we reclaim space later but do not block
the image for minutes anymore.

Cheers
Philippe



More information about the Squeak-dev mailing list