On Fri, Jun 7, 2013 at 1:24 PM, Stéphane Ducasse
<[email protected]>wrote:

> Hi eliot
>
> probably a really stupid question.
> But why count the number of finalization would have a link with the size?
>

The size can only change when a) an element is added or removed, or b) when
something is finalized.  a) adjusts the tally, b) does not.  So
invalidating the size on b) means that it will always be recomputed if
finalization affects the size.


> Is there an invariant that would mean that there is a one one relations
> between object in the set and their garbage collection.
> I mean if two objects of the same weakset are garbage collected will the
> finalization process runs twice
>

No.  Finalization runs once after each GC that finalizes something. i.e.
the GC runs, and if it deletes one or more elements from any of the weak
collections in the system it signals the finalization semaphore.  So the
finalization loop runs once for each GC that finalizes at least one weak
collection.  If a GC finalizes many weak collections the finalization loop
still runs only once for the GC.

>
> I did not look at the class comment because may be it explains it and now
> I 'm dead.
>
> Stef
>



-- 
best,
Eliot

Reply via email to