lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]

On 1-Dec-06, at 11:16 PM, Diego Nehab wrote:


I don't claim to understand what is going on with the new
garbage collector. :) What I want to know is if there is a
simple way to cause the garbage collector notice the
difference between a simple boxed pointer, and a boxed
pointer that represents a big chunk of memory. Creating a
bunch of small userdata with no references to them is fine,
as long as there is not a lot of external memory associated
to them. In the later case, it would be nice if the GC could
be made more reactive.

I guess the hackish way to do that would be to invade the userdata object once it's been created and add to its size the amount of memory actually being used. You'd have to update Lua's record of how much memory has been allocated by the amount you added.

Although seriously impolite to the internals of Lua, that should be safe provided you never refer to lua_objlen of the userdata or replace the standard memory allocation function with something that actually uses the allocation length.

It would be interesting to know if that actually makes a difference to program behaviour, anyway.