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

Gary Chambers gazzaguru2 at btinternet.com
Mon Feb 25 15:25:26 UTC 2008


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.

Regards, Gary.




More information about the Squeak-dev mailing list