|
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.lua262172.40332031464729.12695312real 13m44.993suser 13m38.374ssys 0m0.747s> time ./luarc test.lua262184.49316406262184.49316406real 4m36.861suser 4m37.461ssys 0m0.137s2016-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"))prints262166.11035156445760.78710938problem: 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