lua-users home
lua-l archive

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


> I reproduced the ever-increasing memory behavior with a simple script.
> 
> local mt = {
>         __gc = function() end
> }
> for i = 1, math.pow(10, 9) do
>         setmetatable({}, mt)
>         if (i % math.pow(10, 6)) == 0 then print(collectgarbage'count') end
> end
> 
> In Lua 5.3.5, the memory grows to 1GB within a few seconds.
> In Lua 5.2 and 5.4, it still grows to few MBs, but very slowly.
> Setting the GC pause to 100 or less seems to solve this issue. Is this the
> correct solution?

I tested with the current 5.4 version in github. It oscilates around
40~70 kilobytes. The maximum grows slowly until a top of ~132K (after
243426 new tables), and then it stops growing.

But it seems to be a "fact of live" that programs that create too
many objects with finalizers are subject to garbage-collection
issues, not only in Lua.

-- Roberto