[ANN][VM] Ephemerons for Squeak

Stephen Pair stephen at pairhome.net
Mon Aug 11 13:22:36 UTC 2003


Chris Muller wrote:

>Hi Andreas,
>
>  
>
>>While this problem can be always be solved in any given concrete 
>>situation by using one of the various weak association types, choosing 
>>the 'right' kind of association depends on a variety of factors some of
>>which 
>>can change dynamically.
>>    
>>
>
>Can you help me understand what you meant by this?  I've been using a simple
>scheme for attaching properties to objects using Weak dictionaries.
>
>My "registry" is constructed as:
>
>((a WeakIdentityKeyDictionary)
>	keys:  each object with additional properties
>	values:
>		((a Dictionary)
>			keys:  propertyName
>			values:  the property value)
>
>Using this structure, once the object-with-additional-properties is garbage
>collected, it's key is removed from the Weak dictionary, along with it's entire
>Dictionary of properties.
>
>I'll be excited if ephemerons can somehow improve on some limitation or bug
>that I've overlooked.  Alas, I don't see it at the moment, can you enlighten
>me?
>  
>
IIRC, the major benefit to ephemerons is that the imitate inst vars better.  With the normal weak dictionary that you show here, if a value in the dictionary refers back (directory or indirectly) to its corresponding key, then that key will never get released.  With a weak dictionary based on ephemerons, it would (provided, of course, that the reference(s) from the ephemerons value(s) is/are the only references to the key.

With a little enhancement, Ephemerons could probably replace all uses of WeakKeyAssociation (except of course if you need that special behavior of WeakKeyAssociation).

- Stephen




More information about the Squeak-dev mailing list