Skip to content

Commit

Permalink
add test case to check live_bytes doesn't grow arbitrarily on String(…
Browse files Browse the repository at this point in the history
…::Array{UInt8})) (#54371)

Follow-up to #54331.
  • Loading branch information
d-netto committed May 6, 2024
1 parent 92ccc74 commit 800f67a
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions test/gc.jl
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,25 @@ function run_pg_size_test()
@test page_size == (1 << 12) || page_size == (1 << 14)
end

function issue_54275_alloc_string()
String(UInt8['a' for i in 1:10000000])
end

function issue_54275_test()
GC.gc(true)
baseline = Base.gc_live_bytes()
live_bytes_has_grown_too_much = false
for _ in 1:10
issue_54275_alloc_string()
GC.gc(true)
if Base.gc_live_bytes() - baseline > 1_000_000
live_bytes_has_grown_too_much = true
break
end
end
@test !live_bytes_has_grown_too_much
end

# !!! note:
# Since we run our tests on 32bit OS as well we confine ourselves
# to parameters that allocate about 512MB of objects. Max RSS is lower
Expand All @@ -44,6 +63,10 @@ end
run_pg_size_test()
end

@testset "issue-54275" begin
issue_54275_test()
end

@testset "Base.GC docstrings" begin
@test isempty(Docs.undocumented_names(GC))
end

0 comments on commit 800f67a

Please sign in to comment.