lua-users home
lua-l archive

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


On 5/30/2016 8:31 PM, Rodrigo Azevedo wrote:
I'm not sure

rodrigo@rodrigo-Vostro-5470:~$ cat teste5.lua
N = 1.0e7
C = {}
for i=1,N do C[i] = i end

print(collectgarbage("count"))

for i=1,10*N do
     local a = {1,2,3,4}
end

print(collectgarbage("count"))
rodrigo@rodrigo-Vostro-5470:~$ lua5.2 teste5.lua
262167.40917969    419
445742.6796875    696
rodrigo@rodrigo-Vostro-5470:~$ nano teste5.lua
rodrigo@rodrigo-Vostro-5470:~$ lua5.2 teste5.lua
262166.66113281    677
445487.28613281    293
rodrigo@rodrigo-Vostro-5470:~$ cat teste5.lua
collectgarbage("generational")
N = 1.0e7
C = {}
for i=1,N do C[i] = i end

print(collectgarbage("count"))

for i=1,10*N do
     local a = {1,2,3,4}
end

print(collectgarbage("count"))
rodrigo@rodrigo-Vostro-5470:~$

IIRC in JavaScript it used to be normal to reduce object creation as much as possible in the high performance sections of an app.

I'm curious, what are your program's requirements -- batch or real-time interactive? If you're doing real-time interactive, I think you should just do some rewriting to reduce object creation... I like to engineer a sane system, after all, there is only so much garbage collection can do...

--
Cheers,
Kein-Hong Man (esq.)
Kuala Lumpur, Malaysia