Closed ghost closed 4 years ago
make sure they are not unreferenced, e.g. by using a file like this:
-- nogc.lua
local _nogc_reg={}
return function(object)
table.insert(_nogc_reg, object)
end
then you can do:
local nogc=require("nogc")
local something={1,2,3}
nogc(something)
the idea is: require
caches modules VM wide, so the upvalue table _nogc_reg
is referenced through said cache, and contains a reference to something
so the GC will leave that alone.
If i want to create a UObject, In C++, i need to AddRefrenceObject to avoid the GC, But in lua, if i create a UObject, where shound i put the AddRefrenceObject code to? How do you avoid the GC in your lua framework?