lua-users home
lua-l archive

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

Hi there!

foo = {}
wtable[foo] = setmode({1, 2, foo, 4}, "k")
foo = nil
[ lots of other stuff not involving wtable]

Will 'foo' be GC'able (and more to the point will Lua actually
GC it)?  The only surviving way to 'get at' foo is indirectly
through the [foo] key of wtable, and wtable is weak-keyed, so
foo is the only thing keeping itself alive and thus it might
reasonably be argued that 'foo' is GC'able.

It looks like it'd probably be tough to implement such GC
semantics though, so I'm guessing that no-one does.

(This question isn't quite academic -- I just came across a
case where the above aggressive behaviour would be quite

Adam D. Moss   -