Skip to content

Commit 800f67a

Browse files
authored
add test case to check live_bytes doesn't grow arbitrarily on String(::Array{UInt8})) (#54371)
Follow-up to #54331.
1 parent 92ccc74 commit 800f67a

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

test/gc.jl

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,25 @@ function run_pg_size_test()
2828
@test page_size == (1 << 12) || page_size == (1 << 14)
2929
end
3030

31+
function issue_54275_alloc_string()
32+
String(UInt8['a' for i in 1:10000000])
33+
end
34+
35+
function issue_54275_test()
36+
GC.gc(true)
37+
baseline = Base.gc_live_bytes()
38+
live_bytes_has_grown_too_much = false
39+
for _ in 1:10
40+
issue_54275_alloc_string()
41+
GC.gc(true)
42+
if Base.gc_live_bytes() - baseline > 1_000_000
43+
live_bytes_has_grown_too_much = true
44+
break
45+
end
46+
end
47+
@test !live_bytes_has_grown_too_much
48+
end
49+
3150
# !!! note:
3251
# Since we run our tests on 32bit OS as well we confine ourselves
3352
# to parameters that allocate about 512MB of objects. Max RSS is lower
@@ -44,6 +63,10 @@ end
4463
run_pg_size_test()
4564
end
4665

66+
@testset "issue-54275" begin
67+
issue_54275_test()
68+
end
69+
4770
@testset "Base.GC docstrings" begin
4871
@test isempty(Docs.undocumented_names(GC))
4972
end

0 commit comments

Comments
 (0)