lua-users home
lua-l archive

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

If a Lua (5.1) function creates a local variable(actually it is a userdata and metatable with __gc method set ) and returns it to Cpp pushing it onto the stack, when does the garbage collector kick in for this variable.?
Is it when the value is popped off the stack that the variable becomes "no longer active" or at a later time?
" About the objects stored within local variables: at the moment the local variable is no longer active the GC may collect the object that was stored there. The actual freeing of the object has nothing to do with function scopes or variable live times. The GC runs at certain times and frees all objects that are no longer accessible by any L"