lua-users home
lua-l archive

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


> Could this condition be triggered due to heap fragmentation?
> For example:
> 1. Lua runs out of memory.
> 2. Emergency GC is executed, some memory is actually freed. Heap is
> severely fragmented.
> 3. Lua tries to store some data, which normally should fit into the heap
> (due to previous GC). Due to high fragmentation allocation fails.
> 4. Lua calls emergency GC.
> 5. Repeat...

If memory allocation fails after an emergency GC, then there is a
real failure and pcall should return, finishing your program.


> I am pretty confident that the issue is caused by the GC. I measure the
> stack exactly before and after lua_pcall(),
> and indeed this is where the stack is used. I also placed some prints and I
> see that stack usage increases only when
> GC is running.
> 
> Note that stack is used progressively. On every GC call, more and more is
> requested till the exhaustion. On the first
> calls the usage is pretty minimal.

Have you checked that after each GC call the stack is back where it
started (basic correct C behavior)?

-- Roberto