New option "setparms" for 'collectgarbage'

The generational mode also uses the parameters for the incremental
mode in its major collections, so it should be easy to change those
parameters without having to change the GC mode.
This commit is contained in:
Roberto Ierusalimschy
2023-12-22 14:48:07 -03:00
parent ad0ea7813b
commit e2cc179454
13 changed files with 163 additions and 78 deletions

View File

@@ -27,17 +27,20 @@ end
-- test weird parameters to 'collectgarbage'
do
collectgarbage("incremental")
local opause = collectgarbage("setparam", "pause", 100)
local ostepmul = collectgarbage("setparam", "stepmul", 100)
local t = {0, 2, 10, 90, 500, 5000, 30000, 0x7ffffffe}
for i = 1, #t do
local p = t[i]
collectgarbage("setparam", "pause", t[i])
for j = 1, #t do
local m = t[j]
collectgarbage("incremental", p, m)
collectgarbage("setparam", "stepmul", t[j])
collectgarbage("step")
end
end
-- restore original parameters
collectgarbage("incremental", 200, 300)
collectgarbage("setparam", "pause", opause)
collectgarbage("setparam", "stepmul", ostepmul)
collectgarbage()
end