lua-users home
lua-l archive

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


Tom Spilman wrote:

> It seems that the first garbage collection pass will
> free a table ( the class members are in a table ), but will not free
> newly unreferenced members of that table.

Maybe I'm missing some point here, but Lua uses a mark and sweep gc scheme
that will pinpoint all unreachable data in one go and collect it.  So all
table members will be collected in the same cycle (that is, if they are not
reachable along some other route of course.)

Closing resources in a gc enabled system can not always be left to gc
entirely.  Sometimes resources may be referenced longer than you might
expect (e.g. lingering register values) or the order in which they are freed
can be hard to control.  (I'm not exactly sure if this applies to Lua 4/5
and I can never remember how Lua handles gc calling order.)  If it is
vitally important that resources are freed asap then you probably need to
keep track of those yourself.

Bye,
Wim