lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


Mark Hamburg wrote:
on 1/9/04 4:39 PM, Adam D. Moss at adam@gimp.org wrote:
If you create a new reference to the object within the __gc
callback then the object will safely survive the GC.

I hadn't realized that Lua supported resurrection. That's potentially good
from an allocation speed standpoint and bad from the standpoint that it
makes the semantics more complicated. Is the resurrected object eligible for
repeat finalization?

Now I'm not so sure that what I said is right (though it's
not necessarily wrong :)) -- I just checked the only place
in my code where I need resurrection, and I'm doing a shallow
copy of the object's attributes into a new object with a new dtor,
instead of simply making a new ref.  I don't know if simply taking
a new *local* ref (ie. one that doesn't outlive the running of the
dtor function) still causes the object to be collected (I would
expect so), but a longer-living one should cause the object to
continue to live.  The GC might re-fire -- it doesn't for me, but
that might be because of the additional semantics my class system
adds for dtors which doesn't really take trivial resurrection into
account.

--Adam
--
Adam D. Moss   . ,,^^   adam@gimp.org   http://www.foxbox.org/   co:3