lua-users home
lua-l archive

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

>Good points. I just figured it would all simply be garbage collected.
>To make a bit more clear, in the following example, is what the string
>says correct?
>foo = {}
>bar = {"This string is never cleaned up."};
>foo[bar] = nil;
>bar = nil;
>while(true) do end

After looking at the very top of lgc.c, I can now agree with Hans - the string
will be collected. (Although not in the example given - the gc won't get run
after the line foo[bar] = nil)

The only thing that is reserved is the space for that node. The key itself can be
freed, provided nothing points to it (which means that next will never be called
with the key).

Again, I wish I'd looked at the implementation before guessing =P. Still, learnt
a bit more about the gc today..