|
```lua
collectgarbage('generational',
10, 50)
debug.sethook(function () end,
'c')
print(_VERSION)
print(collectgarbage('count'))
local t = {}
for i = 1,
100000 do
t[i] = (' '):rep(5000)
.. tostring(i)
end
print(collectgarbage('count'))
t = nil
collectgarbage()
collectgarbage()
print(collectgarbage('count'))
local t = {}
for i = 1,
1000 do
t[i] = (' '):rep(100000)
.. tostring(i)
t[i] = nil
if i % 100 == 0 then
print(collectgarbage('count'))
end
end
```
Run this code, prints:
```
Lua 5.4
22.7333984375
595727.66894531
84.794921875
19628.545898438
39172.432617188
58716.319335938
78260.206054688
97804.092773438
117347.97949219
136891.86621094
156435.75292969
175979.63964844
195523.52832031
```
Seems GC stops working.
But if I set
parameters for `collectgarbage` to default (`20, 100`, makes it more negative), it works fine.
This line `debug.sethook(function () end, 'c')`
is not necessary. If you remove this line, you need to set the GC parameters to `10, 20` to reproduce this problem.
-- sumneko
|