[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: GC and userdata objects
- From: Dibyendu Majumdar <mobile@...>
- Date: Thu, 12 Apr 2018 13:35:02 +0100
On 12 April 2018 at 12:53, steve donovan <email@example.com> wrote:
> On Thu, Apr 12, 2018 at 12:41 PM, Viacheslav Usov <firstname.lastname@example.org> wrote:
>> about deterministic collection/finalization. The principal issue is that
>> some userdata are much more than a handful of bytes, they can be handles,
>> connections, money and what not.
> This is the important point. I first encountered this issue when doing
> Lua on top of Java in Android - the userdata could contain really big
> objects like images, but the Lua GC had no way of knowing this. A GC
> on top of a GC! I recall that Eric Wing had similar issues with his
> ObjectiveC/Lua bridge.
> I must say I like the idea of deterministic resource finalization,
> although I understand it has runtime implications.
As I was writing my initial post I did think about suggesting a
try/finally type approach. But the problem with Lua is that it has
adopted a longjmp based exception handling method ... this makes it
hard / maybe impossible to implement deterministic 'finally' type
clause. When Java code calls C code via JNI, the exception handling is
not done using longjmps.