lua-users home
lua-l archive

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


You can try luarc (https://github.com/zenkj/luarc-5.1), Refcount GC is added upon the normal incremental Mark&Sweep GC.

The result:
> time ./lua test.lua
262172.40332031
464729.12695312

real    13m44.993s
user    13m38.374s
sys     0m0.747s

> time ./luarc test.lua
262184.49316406
262184.49316406

real    4m36.861s
user    4m37.461s
sys     0m0.137s


2016-05-29 1:03 GMT+08:00 Rodrigo Azevedo <rodrigoams@gmail.com>:
The code

N = 1.0e7
C = {}
for i=1,N do C[i] = i end
print(collectgarbage("count"))
for i=1,100*N do
        local a = {1,2,3,4}
end
print(collectgarbage("count"))

prints

262166.11035156
445760.78710938

problem: when Lua uses lot of memory, the creation of temporary objects can consume all your memory. I think CG should collect the objects fast enough, but it does not. A perfectly OK program can't run because of the amount of garbage to be collected consumes all memory.

I overcome this situation using collectgarbage() options inside the "for", but the performance is severely degraded. (due to the high number of objects GC need to manager, or the manual increase of the number of cycles.)

question: There is some place of Lua source code that I can modify to keep the memory usage as close as possible to 262166.11035156 without doing my program 3x slowly?



--
Rodrigo Azevedo Moreira da Silva