[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: [PATCH] Humble request: Invoke finalizers repeatedly for resurrected data
- From: Tim Hill <drtimhill@...>
- Date: Sat, 3 May 2014 11:09:31 -0700
On May 3, 2014, at 9:37 AM, Karel Tuma <firstname.lastname@example.org> 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.