[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: 5.1 collectgarbage: test case
- From: "William Trenker" <wtrenker@...>
- Date: Sun, 12 Mar 2006 00:26:12 -0800
This code segment initializes a table with values 1 to 10000. It then
removes all the elements except the last. Question: why has the
memory count not been reduced?
t = {}
for n = 1,10000 do
table.insert(t,n)
end
collectgarbage("collect")
print("MEM:",collectgarbage("count"))
for n = 1, #t-1 do
table.remove(t, 1)
end
collectgarbage("collect")
print("MEM:",collectgarbage("count"))
table.foreach(t,print)
prints:
MEM: 275.8583984375
MEM: 275.8583984375
1 10000
I've run this on both Linux and WinXP with the same results.
Thanks,
Bill