lua-users home
lua-l archive

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


Gang,

I'm heavily using userdata items and want to be able to reuse them once lua scripts are done with them instead of constantly creating new ones, which causes more frequent gc.

But I'm unclear on the use of the userdata finalizer. If a userdata has a metatable with a __gc field, I know it gets called but does the GC mechanism then still collect the userdata object after calling it?

I'd ideally like it to NOT collect the userdata object so that I can, say, stash it in some table (so it won't be collected) and then when I need to use a userdata, I can get the stashed one and reset its value, instead of having to allocate a new one.

Is this feaseable? I'm not on my dev machine so I can't determine this empirically...

thx,
ando