lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


> I need an efficient way to determine whether a container is no longer
> referenced by Lua.

I can think of only one way to do this. You'll need a table with a
metatable with __mode = 'v'. When you allocate an object you also save
it in that table with a lightuserdata based on the address of the
object as key. Then when you want to know whether there are still
references to an object outstanding, simply check whether the key/value
pair still exists in the table. That should do the trick, though I'm not
sure whether you should consider it a proper solution or a hack... HTH,

Peter Odding