On Wednesday, Aug 13, 2003, at 12:39 Europe/Berlin, Edi Weitz wrote:

>
> On 10 Aug 2003 01:01:21 +0200, I wrote:
>
>> Hi!
>>
>> I have an application where I will have two hash tables around, one
>> to map certain objects to a structure providing information about
>> them, the other one to map identifiers to objects (the same set of
>> objects). I want both hash tables to be weak, i.e. I want the
>> respective entries in both hash tables to disappear when the object
>> in question is no longer referenced.
>>
>> ...
>> 1. Have a CMUCL-weak hash table H1 where the objects are keys and
>>    the values are structures keeping information about the objects.
>>
>> 2. Have another, normal, hash table H2 where the values are weak
>>    pointers to the same objects.
>>
>> 3. Once an object won't be referenced from elsewhere the respective
>>    entry in H1 will disappear automatically while the weak pointer in
>>    H2 which points to this object will be broken.
>>
>>    Is that correct or do the weak hash key and the weak pointer
>>    somehow interact and thus prevent the object from being garbage
>>    collected?
>
i'm surprised that you would not want H2 to be weak on the key. it's 
purpose is to permit users to retain the objects by virtue of binding 
the keys, isn't it? done this way, it takes two passes to release the 
objects, but no gc hooks. in either case, my concern would be about 
references from the object to its respective key, unless the gc 
implementation makes allowances for that.
...


Reply via email to