diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2023-12-27 12:09:11 -0300 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2023-12-27 12:09:11 -0300 |
commit | 12b6f610b0f1b4157c04f0db264f1f1d0634709b (patch) | |
tree | 198881cf4ac938aa9082fe7781d575e359d9bf09 /testes | |
parent | e81f586001d767c8de9b760ae2e2c3b5da1542c6 (diff) | |
download | lua-12b6f610b0f1b4157c04f0db264f1f1d0634709b.tar.gz lua-12b6f610b0f1b4157c04f0db264f1f1d0634709b.tar.bz2 lua-12b6f610b0f1b4157c04f0db264f1f1d0634709b.zip |
Several tweaks in the garbage collector
- back with step size in collectgarbage("step")
- adjustments in defaults for some GC parameters
- adjustments in 'luaO_codeparam'
Diffstat (limited to 'testes')
-rw-r--r-- | testes/files.lua | 2 | ||||
-rw-r--r-- | testes/gc.lua | 29 |
2 files changed, 30 insertions, 1 deletions
diff --git a/testes/files.lua b/testes/files.lua index 2582406f..4f925f50 100644 --- a/testes/files.lua +++ b/testes/files.lua | |||
@@ -74,6 +74,8 @@ io.input(io.stdin); io.output(io.stdout); | |||
74 | 74 | ||
75 | os.remove(file) | 75 | os.remove(file) |
76 | assert(not loadfile(file)) | 76 | assert(not loadfile(file)) |
77 | -- Lua code cannot use chunks with fixed buffers | ||
78 | checkerr("invalid mode", load, "", "", "B") | ||
77 | checkerr("", dofile, file) | 79 | checkerr("", dofile, file) |
78 | assert(not io.open(file)) | 80 | assert(not io.open(file)) |
79 | io.output(file) | 81 | io.output(file) |
diff --git a/testes/gc.lua b/testes/gc.lua index 8bacffa0..c26de406 100644 --- a/testes/gc.lua +++ b/testes/gc.lua | |||
@@ -35,7 +35,7 @@ do | |||
35 | collectgarbage("setparam", "pause", t[i]) | 35 | collectgarbage("setparam", "pause", t[i]) |
36 | for j = 1, #t do | 36 | for j = 1, #t do |
37 | collectgarbage("setparam", "stepmul", t[j]) | 37 | collectgarbage("setparam", "stepmul", t[j]) |
38 | collectgarbage("step") | 38 | collectgarbage("step", t[j]) |
39 | end | 39 | end |
40 | end | 40 | end |
41 | -- restore original parameters | 41 | -- restore original parameters |
@@ -45,6 +45,33 @@ do | |||
45 | end | 45 | end |
46 | 46 | ||
47 | 47 | ||
48 | -- | ||
49 | -- test the "size" of basic GC steps (whatever they mean...) | ||
50 | -- | ||
51 | do print("steps") | ||
52 | |||
53 | local function dosteps (siz) | ||
54 | collectgarbage() | ||
55 | local a = {} | ||
56 | for i=1,100 do a[i] = {{}}; local b = {} end | ||
57 | local x = gcinfo() | ||
58 | local i = 0 | ||
59 | repeat -- do steps until it completes a collection cycle | ||
60 | i = i+1 | ||
61 | until collectgarbage("step", siz) | ||
62 | assert(gcinfo() < x) | ||
63 | return i -- number of steps | ||
64 | end | ||
65 | |||
66 | collectgarbage"stop" | ||
67 | |||
68 | if not _port then | ||
69 | assert(dosteps(10) < dosteps(2)) | ||
70 | end | ||
71 | |||
72 | end | ||
73 | |||
74 | |||
48 | _G["while"] = 234 | 75 | _G["while"] = 234 |
49 | 76 | ||
50 | 77 | ||