[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: gc problem when using lightuserdata to reference C++ objects
- From: "Javier Guerra" <javier@...>
- Date: Fri, 14 Nov 2008 09:43:40 -0500
On Fri, Nov 14, 2008 at 9:22 AM, Florian Weimer <fw@deneb.enyo.de> wrote:
> * Javier Guerra Giraldez:
>
>> in short, just add a 'close' method to the Lua object, and call it
>> as soon as you don't need it.
>
> Is there a short idiom to express this sort of resource management in
> the presence of exceptions?
i'd say no. GC isn't a panacea, nor an automatic resource management.
if you really want it to help, i'd say go with Jerome's suggestion,
and store the whole C++ object in the Lua-allocated full userdata. Of
course, that helps only if it's a really heavy object, and not a
complex weave of interrelated things. (unless you manage to store
them all in one or several Lua objects).
--
Javier