lua-users home
lua-l archive

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


Paul Hsieh wrote:
> 
> As the subject says, I've implemented a per-tag explicit garbage collection.
>...
> I'd like to know what people think of this, and whether or not people think
> this, or something like it should go into a future version of Lua.

Ehh... what's the point?  You do all the dirty work of walking the whole
heap to determine what objects are stale and when it's actually time to
free stuff you stop and only free userdata objects with some special tag.
You save time by not freeing objects - strange decision ;-)

Beside that, you'll have some problems with already collected userdata
objects still hanging around in TMtable[].collected.  They are disconnected
from the userdata hash and a pushuserdata will create a new object.  That
way you may get multiple objects with same userdata-value.  The gc method
may be confused...

Oh, and you waste memory!  You do not unmark objects.  So the next time
the gc runs, these objects will not be collected even if they are no
longer in use...  Uhh, I think this will even bomb in some circumstances
(userdata in table, table still marked but userdata was unmarked, next
time table will not be scanned because already marked, userdata not marked
again, collected later, but still reference in table, boom).

Ciao, ET.