diff options
author | Peter Zhu <[email protected]> | 2025-06-26 11:34:31 -0400 |
---|---|---|
committer | Peter Zhu <[email protected]> | 2025-06-26 16:38:39 -0400 |
commit | 26508bbc46bcda703c8d76a3b287f71e3967bdbd (patch) | |
tree | 439aa5bf91391958fd637c4ab256142c8747bee6 | |
parent | aca692cd41d4cf74f5b5d35a703b55262ff4bcf8 (diff) |
Fix flaky TestGc#test_heaps_grow_independently
The test sometimes fails with "Expected 2062788 to be < 2000000" because
heap 0 has not been cleared yet by GC. This commit fixes it to run GC
before the assertion to ensure that it does not flake.
-rw-r--r-- | test/ruby/test_gc.rb | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/test/ruby/test_gc.rb b/test/ruby/test_gc.rb index 3516cefedf..85022cbc4d 100644 --- a/test/ruby/test_gc.rb +++ b/test/ruby/test_gc.rb @@ -701,6 +701,11 @@ class TestGc < Test::Unit::TestCase allocate_large_object end + # Running GC here is required to prevent this test from being flaky because + # the heap for the small transient objects may not have been cleared by the + # GC causing heap_available_slots to be slightly over 2 * COUNT. + GC.start + heap_available_slots = GC.stat(:heap_available_slots) assert_operator(heap_available_slots, :<, COUNT * 2, "GC.stat: #{GC.stat}\nGC.stat_heap: #{GC.stat_heap}") |