[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Confused by Lua garbage collection tear down order when there are references between objects
- From: Roberto Ierusalimschy <roberto@...>
- Date: Thu, 22 May 2014 10:16:08 -0300
> I tried doing a simpler mockup to see what happens if I create
> newuserdata during an object's finalizer. It looks like the problem is
> still lua_close. But this time it looks like that lua_close may not
> get around to cleaning up these new objects at all.
This is documented behavior:
When you close a state (see lua_close), Lua calls the finalizers of
all objects marked for finalization, following the reverse order that
they were marked. If any finalizer marks new objects for collection
during that phase, these new objects will not be finalized.
(Otherwise bad objects could create a loop so that 'lua_close' would
never finish.)
-- Roberto