[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: Garbage Collection
- From: "Thatcher Ulrich" <tu@...>
- Date: Wed, 30 Oct 2002 14:28:34 -0500
On Oct 30, 2002 at 04:10 -0300, Roberto Ierusalimschy wrote:
> > Does the Lua core always use the set* macros to change a Value's state?
> Yes (or it should), but this is not enough. As we discussed for the
> stack, we still need some way to catch creation/destroying of references
> (and not only changes).
Good point. If new Value objects are always initialized to nil, then
that should take care of creation. I suppose that's not already being
For destruction of stack references, it can be safely deferred, like
we discussed. So, in the GC's where this is necessary, it can be
deferred all the way until luaC_collect is called. To get earlier
collection of things referred to by the stack, an explicit
lua_cleanstack() API could be added, or perhaps it could be done in
luaD_checkstack(). Basically, it needs to call setnilvalue() on all
entries of the stack above the current top. So I think this stack
cleaning could easily be part of a GC patch -- it doesn't need to be
included in the core.
For destruction of non-stack references, it would suffice to set all
Values to nil with setnilvalue() when they are destroyed. I suppose
this also is not being done currently, but then I haven't looked.