[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: Child states and garbage collection
- From: Roberto Ierusalimschy <roberto@...>
- Date: Mon, 13 Sep 2004 10:02:05 -0300
> should doing my luaL_ref(childState, LUA_REGISTRYINDEX) with the entry
> point be enough to prevent GCing of the childState?
By default, child threads share the registry with the main thread.
If you do not change that, then your references are kept at the main
registry, and therefore should not be collected. However, if you change
a child's registry, then any reference to the child in its own registry
is a circular reference, and as such is not enough to prevent GC.
As a matter of style, you should keep the child's reference in the main
registry, even if it happens to be the same registry as the child's.
(Just in case: what version of Lua are you using?)