lua-users home
lua-l archive

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


> You can do the same in Lua:
>
>   collectgarbage("stop")
>   collectgarbage("restart")
>   collectgarbage("collect")  (equivalent to collectgarbage())
>   collectgarbage("count")
>
> -- Roberto
>

Well, I tried a simple test, but lua complained -- I think the arguments
to collectgarbage need to be ints rather than strings!

Here's my quick attempt:

n = 0
a = ""
for i = 1, 1000 do
    for j = 1, 1000 do
        a = a .. "X"
    end
    n = n + 1000
--  garb = collectgarbage("count")
--  print("at n =", n, "", "count garbage:", garb)
    print("at n =", n)
--  collectgarbage("collect")
    collectgarbage(4)
end
print("at end, len(a) =", string.len(a))


(the commented out lines are where lua complained).

Anyway, I found it started quite spritely but, now at n = 296000 it's very
slow (99.1% cpu according to top). For a while I had 5.1work and 5.0.2
running the same script in two windows (impressionistically they seemed
equivalent).

I like doing concats as a torture test.

Joe