lua-users home
lua-l archive

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

As far as I understood the GC operation, all objects for that a __gc function is called are put aside for another run of the GC which is performed after all __gc functions have been called.


Am 21.03.2014 01:54, schrieb Rena:
I've just noticed a strange issue with garbage collection in my Lua code. The code is quite large, would be difficult to create a test case, but the basics are:

1) Create a userdata object
2) Store it as a key in a table in the registry
3) Create more objects
4) Close the Lua state
5) The object created in step 1 is collected and its __gc is called
6) Other objects' __gc look in the table in the registry, and that object is still there!

How can __gc be called and the object not be removed from the table?

Sent from my Game Boy.