lua-users home
lua-l archive

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


> On Nov 9, 2014, at 4:18 PM, Luiz Henrique de Figueiredo <lhf@tecgraf.puc-rio.br> wrote:
> 
> 
>> We also use a custom allocator (for other reasons), but we reserve a block of heap storage at startup. If an allocation fails, we release that reserved memory to the heap and retry the allocation. 
> 
> Lua 5.2 implements a emergency gc that is run when memory allocation fails.
> 

Yes I looked closely at that when we were doing design work. The problem was that we may have many independent Lua states in the same process, and so we needed a global way to release memory across all of them. While I totally understand the desire to keep all Lua states independent, managing memory across a set of states is tricky unless you know in advance how much memory each state needs (which we don’t). One of the things the custom allocator does is track memory usage across each state, which at least helps us track “rogue” Lua states.

—Tim