[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Using Lua and C with a Garbage Collector
- From: SevenThunders <mattcbro@...>
- Date: Wed, 15 Mar 2006 21:05:04 -0800 (PST)
Maybe I'm not understanding something in your suggestion. As I understand it
it wouldn't matter if I used the metatable mechansim to automatically call
the Boehm garbage collector inside LUA. The Boehm gc has to search through
memory to verify that all allocated buffers are still reachable via some
variable/buffer in the workspace. To do that it has to do a tree walk
through all the pointers in it's root set and then all the pointers that
they point to etc. If I allocate a buffer that immediately disappears into
LUA it is completely unreachable by the Boehm garbage collector.
What buffer in the C data segment holds a pointer or a pointer to a pointer
et. al. allocated by the Boehm gc, that contains my C buffer now stored in
Lua? The Boehm gc has no idea what malloc/realloc is doing or what is in
the buffer created by these functions, thus it must eventually mark the C
buffer in LUA as unreachable and garbage collect it, causing memory faults
etc. Perhaps if LUA had key root sets on the stack or in some register, it
could avoid getting collected for a while. But my experience with this
suggests that it's not long before disaster strikes.
--
View this message in context: http://www.nabble.com/Using-Lua-and-C-with-a-Garbage-Collector-t1281804.html#a3430153
Sent from the Lua - General forum at Nabble.com.