[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: [ANN] Lua 5.2.1 (work1) now available
- From: Rena <hyperhacker@...>
- Date: Sat, 7 Apr 2012 00:42:38 -0600
On Fri, Apr 6, 2012 at 03:12, Miles Bader <miles@gnu.org> wrote:
> Miles Bader <miles@gnu.org> writes:
>> Each call to "pos" will allocate a small userdata object, which is not
>> referenced by anything -- pure garbage!
>
> BTW, I should note that the way SWIG allocates objects like this is to
> use C++ "new" to create the actual object, and then allocate a Lua
> userdata containing a pointer to the C++ object, some info about its
> type, and a Lua metatable with a __gc entry that does the deallocation.
>
> I don't think it's particularly efficient for small objects like this,
> but as far I can tell it does the right thing, and the userdata in
> this case is about the same size as the referenced data, so Lua's GC
> should have roughly the right idea of how much memory is being used.
>
> -Miles
>
> --
> Cat is power. Cat is peace.
>
A boxed pointer, in other words. I don't know of any other method to
deal with C++ objects that expect the use of new and delete.
--
Sent from my toaster.