[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Resurrecting Objects
- From: Roberto Ierusalimschy <roberto@...>
- Date: Tue, 12 Nov 2013 18:33:08 -0200
> I'm not entirely sure if I understood your problem, because, as
> someone else in this thread already mentioned, weak table entries
> either are collected (and removed from the weak table) or they are
> not (and still there).
For objects with no finalizers, the above reasoning is perfect.
However, for objects with finalizers, there are some details in the
interaction between weak tables and finalizers:
1) A finalizer always "resurrect" the object, as while it runs it
has a strong reference to the object (and can even store that reference
somewhere else).
2) If an object with a finalizer is a *key* in a weak table, it is not
removed from the table when it is first "collected" (that is, cleared
from weak-table values and marked for finalization). That should not
be a problem, unless you traverse that table. (Otherwise, you cannot
access that entry anyway.) If you do traverse weak tables where keys
are objects with finalizers, you may need some extra structure to
distinguish objects that have been marked for finalization.
-- Roberto