[Pharo-project] Another fixes to finalization (was Re: [update 1.2] #12161 - #12172)

Henrik Sperre Johansen henrik.s.johansen at veloxit.no
Sun Oct 3 06:03:07 EDT 2010


  On 03.10.2010 11:59, Igor Stasenko wrote:
> On 3 October 2010 12:36, Henrik Sperre Johansen
> <henrik.s.johansen at veloxit.no>  wrote:
>>   On 03.10.2010 05:47, Igor Stasenko wrote:
>>> On 3 October 2010 03:13, Henrik Sperre Johansen
>>> <henrik.s.johansen at veloxit.no>    wrote:
>>>>   On 02.10.2010 19:01, Igor Stasenko wrote:
>>>>> On 2 October 2010 19:47, Stéphane Ducasse<stephane.ducasse at inria.fr>
>>>>>   wrote:
>>>>>> Hi igor
>>>>>>
>>>>>> do you understand why the previous definition was
>>>>>>
>>>>>> cachedDefinitions
>>>>>>         Definitions ifNil: [Definitions := WeakIdentityKeyDictionary
>>>>>> new.
>>>>>>   WeakArray addWeakDependent: Definitions].
>>>>>>         ^ Definitions
>>>>>>
>>>>> i don't. :)
>>>>>
>>>>> It just a way to free memory as fast as possible.
>>>>> But its really not worth spending so much CPU in order to save few
>>>>> bytes of memory.
>>>> Without registering the dict for finalization, the values won't ever be
>>>> removed with the current implementation.
>>> They are removed. After each package load/unload operation.
>>> I don't see a reason to do this more often.
>> If they are removed explicitly, then yes. But then again, if that's the
>> case, why use a weak dictionary in the first place?
> i don't know much about MC to tell for sure.
>
>>>> Which can be somewhat hampering to performance once you have lots of
>>>> nil-keyed elements all stashed from index 1 and onwards after a rehash.
>>>>
>>> In Pharo, weak dict knows how to reuse expired associations:
>>>
>> And when do they expire? Only when they are either finalized, or removed
>> explicitly.
>> So if you do neither, they will stay indefinately without being
>> removed/reused.
> no. they expiring when key become nil.
>
You'd think so, yes.
However, see implementor of WeakKeyAssociation>>#expired, and senders of 
#expire.

Cheers,
Henry




More information about the Pharo-dev mailing list