[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Issues with the garbage collector
- From: "Wesley Smith" <wesley.hoke@...>
- Date: Thu, 30 Nov 2006 13:12:45 -0800
function cb(event)
print("cb: " .. tostring(event))
for k, v in pairs(event) do
print(k)
print("\t" .. tostring(v))
print("")
end
print(table.concat(event.args, ", "))
print(listener)
end
--userdata
local listener = jit.listener("listen", "cb")
local xfade = jit.new("jit.xfade")
In the above script, I have 2 userdata variables. The "listener"
object registers a Lua function as a callback from another part of the
app the script is embedded in. In the C function that passes data to
the Lua callback function, I'm allocating a small table, "event", and
passing it to the callback function. After a certain period of time,
the garbage collector gets called and calls both userdata __gc
functions, freeing them.
My question is how does the GC decide what to free? I don't think
either listener or xfade should be deleted because they're still valid
variables. What is the metric being used by Lua to decide what gets
deleted?
thanks,
wes