lua-users home
lua-l archive

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

That's the point!

Thank you very much.

p.s. Roberto, Luiz, is it possible to include something similar into the next Lua version?

2016-05-29 4:39 GMT-03:00 zejian ju <>:
You can try luarc (, Refcount GC is added upon the normal incremental Mark&Sweep GC.

The result:
> time ./lua test.lua

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

> time ./luarc test.lua

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

2016-05-29 1:03 GMT+08:00 Rodrigo Azevedo <>:
The code

N = 1.0e7
C = {}
for i=1,N do C[i] = i end
for i=1,100*N do
        local a = {1,2,3,4}



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

Rodrigo Azevedo Moreira da Silva