Several tweaks in the garbage collector

- back with step size in collectgarbage("step")
- adjustments in defaults for some GC parameters
- adjustments in 'luaO_codeparam'
This commit is contained in:
Roberto Ierusalimschy
2023-12-27 12:09:11 -03:00
parent e81f586001
commit 12b6f610b0
8 changed files with 98 additions and 56 deletions

View File

@@ -74,6 +74,8 @@ io.input(io.stdin); io.output(io.stdout);
os.remove(file)
assert(not loadfile(file))
-- Lua code cannot use chunks with fixed buffers
checkerr("invalid mode", load, "", "", "B")
checkerr("", dofile, file)
assert(not io.open(file))
io.output(file)

View File

@@ -35,7 +35,7 @@ do
collectgarbage("setparam", "pause", t[i])
for j = 1, #t do
collectgarbage("setparam", "stepmul", t[j])
collectgarbage("step")
collectgarbage("step", t[j])
end
end
-- restore original parameters
@@ -45,6 +45,33 @@ do
end
--
-- test the "size" of basic GC steps (whatever they mean...)
--
do print("steps")
local function dosteps (siz)
collectgarbage()
local a = {}
for i=1,100 do a[i] = {{}}; local b = {} end
local x = gcinfo()
local i = 0
repeat -- do steps until it completes a collection cycle
i = i+1
until collectgarbage("step", siz)
assert(gcinfo() < x)
return i -- number of steps
end
collectgarbage"stop"
if not _port then
assert(dosteps(10) < dosteps(2))
end
end
_G["while"] = 234