[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: Using Lua's memory allocator
- From: Gavin Wraith <gavin@...>
- Date: Tue, 11 Oct 2011 14:23:59 +0100
In message <91EDF0BE-E3EF-435E-BA45-99FF0F4A05FD@gmail.com> you wrote:
> I think that I misunderstood your question. You are perhaps looking
> for a *automatic* garbage collector for C. Lua is in this case *not*
> what you are looking for! Lua garbage collector does not scan the
> content of userdata (or any other type) to find "pointers" to used
> data. An Lua value can be collected if it no more on the stack nor
> referenced in another accessible Lua value.
Sorry, I must have expressed myself badly. The content of the userdata
would not need any scanning. The items handled by the library do not
contain pointers to other items. That is a key simplifying aspect which I
should have mentioned. What the library implements is a first-order
theory - passive data, and binary operations on them.
If I grab some memory using lua_newuserdata, and after using that memory
for the above-mentioned operations simply throw away the pointer to it
(i.e. never push it on the Lua stack), then that memory will be reclaimed
- have I got that right?
Gavin Wraith (firstname.lastname@example.org)
Home page: http://www.wra1th.plus.com/