lua-users home
lua-l archive

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

Francesco Abbate wrote:
> I've a question about Lua/LuaJIT compatiblity. As you know Lua have a
> very peculiar behaviour when you have a table with weak keys and the
> key is un userdata. In this case the key object can be finalized but
> not immediately removed from the table. It will be removed only at the
> next GC cycle.
> As this behaviour is undocumented in Lua 5.1.4 I was wondering if
> LuaJIT is doing exactly the same thing of Lua. For me is important
> because if LuaJIT is doing the same I will need to implement a
> workaround in my code.

LuaJIT 2.0 has the same GC as Lua 5.1. LuaJIT 2.1 will probably
get a new garbage collector.

But this is not a compatibility question. Specific GC behavior is
undocumented on purpose. It's completely up to the GC to decide
when to release an object (or if at all) or when to clear a weak
table entry. There are no other rules. Period.

Your code is broken if it relies on any particular GC behavior.