Re: Garbage collection of userdata inside userdata

Sean Conner <[email protected]> Tue, 14 Jul 2026 18:16:07 -0400
Newsgroups gmane.comp.lang.lua.general
Message-ID <[email protected]>
It was thus said that the Great 'Stefano Cossu' via lua-l once stated:
> Hello,

  Hello.

> Which approach shall I use? I guess I'd want to prevent the independent 
> term set from ever being garbage collected. I can't use a light userdata 
> pointer because the access function must return a full usable Lua 
> object. I also shouldn't duplicate the term set because it's expensive 
> and the two copies could fall out of sync, which is undesirable.

  You might want to add a reference to the TermSet to the DataSet using
LUA_REGISTRYINDEX with the luaL_ref() and luaL_unref() functions.  Using
luaL_ref() will anchor the TermSet until luaL_unref() is called which will
then allow the TermSet to be GCed.

  -spc

-- 
You received this message because you are subscribed to the Google Groups "lua-l" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].
To view this discussion visit https://groups.google.com/d/msgid/lua-l/20260714221607.GA18203%40brevard.conman.org.