[squeak-dev] More finalization enhancements

Levente Uzonyi leves at elte.hu
Mon Feb 22 18:11:54 UTC 2010


Hi,

I have two other ideas to enhance finalization:
1. If WeakKeyDictionary's finalizer is nil, then #finalizeValues can 
return immediately, because if finalizer is nil, we just have to throw 
away the associations which key became nil. The suggested change postpones 
the removal of elements from the dictionary until rehash, grow or a 
(lucky) removal happens. It can save a lot of time if there are large 
WeakKeyDictionaries around (which can easily happen if you load Monticello 
packages).
2. There should be a way to add multiple finalizers for a 
single object. Currently if you send #toFinalizeSend:to:with: to an 
object, it creates an ObjectFinalizer and adds it to the current 
finalization registry. If you send it one more time to the same 
object, the first finalizer will be lost. I see two possible solutions:
  (a) change WeakRegistry to store multiple finalizers per object
  (b) same as (a), but in a subclass of WeakRegistry and Object >> 
#finalizationRegistry returns and instance of this subclass

Ideas? Opinions?


Cheers,
Levente



More information about the Squeak-dev mailing list