On 10 June 2013 05:38, Eliot Miranda <[email protected]> wrote: > > > 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. > i correcting you b) when something is garbage collected.
>> >> 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. Except from the cases, when you put too many things into finalization process, producing much garbage, which causing another GC while running it.. Then it turns into self-supporting process: - running finalization process causing GC - GC causing running finalization process :) >> I did not look at the class comment because may be it explains it and now >> I 'm dead. >> >> Stef > > > > > -- > best, > Eliot -- Best regards, Igor Stasenko.
