lua-users home
lua-l archive

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

On May 3, 2014, at 9:37 AM, Karel Tuma <> wrote:

> But this does not work with Lua, because Lua calls finalizer only once, after
> that it leaks/crashes because it appears the Lua VM holds reference to the
> proxy userdata, while in fact it does not (it just didn't call the finalizer
> again after resurrection).

Calling finalizers once is pretty common in GC-based languages, including .Net and Java. In general, it’s an anti-pattern to have objects that need finalization be resurrected.

If I understand your design correctly, a better approach is not to release the reference on the userdata until you are sure that it is truly no longer needed.