[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Boxed userdata and garbage collector
- From: Francesco Abbate <francesco.bbt@...>
- Date: Fri, 3 Sep 2010 08:53:27 +0200
Hi Sylvain,
I think that since you want that the lua GC manage the allocated
memory you should allocate the memory with lua. You can do that very
easily in C++ with placement new and explicit destructor call or in C
by using the lua_newuserdata instead of malloc to allocate the whole
buffer.
I'm using this techniques both with C and C++ code and it works like a
charm, it is more simple and you reduce memory fragmentation.
I hope that helps.
Francesco