From e2cc179454c6aa6cde5f98954bd3783e0d5d53a3 Mon Sep 17 00:00:00 2001 From: Roberto Ierusalimschy Date: Fri, 22 Dec 2023 14:48:07 -0300 Subject: 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. --- testes/gc.lua | 11 +++++++---- testes/gengc.lua | 5 +++-- 2 files changed, 10 insertions(+), 6 deletions(-) (limited to 'testes') diff --git a/testes/gc.lua b/testes/gc.lua index d7e0c4ff..61b5da9c 100644 --- a/testes/gc.lua +++ b/testes/gc.lua @@ -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 diff --git a/testes/gengc.lua b/testes/gengc.lua index d708d7fc..cae07285 100644 --- a/testes/gengc.lua +++ b/testes/gengc.lua @@ -163,14 +163,15 @@ assert(collectgarbage'isrunning') do print"testing stop-the-world collection" - collectgarbage("incremental", nil, 0) + local step = collectgarbage("setparam", "stepsize", 0); + collectgarbage("incremental") -- each step does a complete cycle assert(collectgarbage("step")) assert(collectgarbage("step")) -- back to default value - collectgarbage("incremental", nil, 200) + collectgarbage("setparam", "stepsize", step); end collectgarbage(oldmode) -- cgit v1.2.3-55-g6feb