diff --git a/tl b/tl index 4f69a4933..c8c49339d 100755 --- a/tl +++ b/tl @@ -55,6 +55,12 @@ do end end +local function check_collect(i) + if i % 50 == 0 then + collectgarbage() + end +end + local function printerr(s) io.stderr:write(s .. "\n") end @@ -717,9 +723,7 @@ do write_out(tlconfig, result, output_file) end - if i > 1 then - collectgarbage() - end + check_collect(i) end local ok = report_all_errors(tlconfig, env) @@ -1184,9 +1188,7 @@ commands["check"] = function(tlconfig, args) end end - if i > 1 then - collectgarbage() - end + check_collect(i) end local ok = report_all_errors(tlconfig, env) @@ -1241,9 +1243,7 @@ commands["gen"] = function(tlconfig, args) end table.insert(results, res) - if i > 1 then - collectgarbage() - end + check_collect(i) end for _, res in ipairs(results) do @@ -1343,9 +1343,7 @@ do tr, trenv = tl.get_types(result, trenv) end end - if i > 1 then - collectgarbage() - end + check_collect(i) end local ok, _, _, w = report_all_errors(tlconfig, env)