Hi Christoph, You may be doing too many re-allocations, which fragments your memory, so you run out of memory even though the used amount is significantly smaller than the total available memory. There are simply no large enough chunks to allocate. Try to preallocate by assigning the largest element first (not sure how LuaJIT handles that) either before your loops or by looping last to first instead of first to last.Paul. On Fri, Mar 22, 2013 at 7:12 AM, Christoph N. Straehle <cstraehle@xxxxxxxxx> wrote: > Hello List, > > > this code snippet reliably crashes with a "PANIC: unprotected error in call > to Lua API (not enough memory)" message on my 64bit linux machine (luajit is > latest git head). > > for i = 1, 40, 1 do > print(i) > local tab_a = {} > local tab_b = {} > for s = 0, 2048*2048, 1 do > table.insert(tab_a, 1) > table.insert(tab_b, 2) > end > end > > this seems strange, as the memory requirement of the two tables should be > 16MB each. > > Greetings, > Christoph >