lua-users home
lua-l archive

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


On Sunday 11, Bogdan Marinescu wrote:
> I find your patch very useful for resource-constrained systems (read
> "most of the medium power micros out there"). That said, I'd rather
> take the patch in its previous form. That is, from a custom allocator
> only. It seems to allow one to "fine tune" the whole allocation
> process better. On the other hand, this is also possible with the
> latest patch, which also allows one to control this behavior directly
> from Lua, so this is fine with me. Very good work.
The only part that will get in the way of a custom allocator that wants to 
control how the GC is called when the allocator return NULL.  I have been 
thinking about removing that part, since it is very easy to create an 
allocator that does a full GC when 'realloc' fails.  The memlimit feature is 
disabled by default and doesn't stop a custom allocator from doing it's 
own 'fine tuned' GC calls.

I could move the memlimit+"emergency GC on failed allocation" code into the 
default allocator that gets replaced by the custom allocator.  This way user 
that don't want to create their own allocator can use the memlimit feature 
and others that want more control can replace it with their own tuned 
allocator.  I think this might be the best option.

The main reason I wanted to add the memlimit feature to the Lua core is that 
the core has access to the "totalbytes" field of structure 'global_State'.  I 
don't want to duplicate that field in a custom allocator just to support the 
memlimit feature.

-- 
Robert G. Jakabosky