[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: __gc() isn't always called.
- From: Joe Gester <joe@...>
- Date: Mon, 08 Sep 2008 16:16:47 -0400
Hi,
I have several full userdatas with metatables and a __gc metamethod
implemented in C. Storing the userdata in a global variable, I can
access its members and call other metamethods like __index and
__newindex as exoected. If my script assigns nil to the global
variable, the __gc method runs. If I assign nil to the variable from C
and use lua_gc to collect the garbage or call lua_close, the __gc method
does not run.
Should __gc called when the references are broken from outside the
script and/or when lua_close is run? Is there something in particular I
ought to be doing to get __gc to run? I would expect it to just work
since garbage is properly collected when the references are broken from
within the script.
-- Joe Gester