From e5ebd045263d2e35b78f566eeaa1503a2e51ee37 Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada Date: Mon, 2 Aug 2021 08:38:30 +0900 Subject: [PATCH] Stop infinite object allocation to get rid of OOM killer --- test/ruby/test_gc_compact.rb | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/test/ruby/test_gc_compact.rb b/test/ruby/test_gc_compact.rb index 7d8bde04f84f89..46683d0ed5747d 100644 --- a/test/ruby/test_gc_compact.rb +++ b/test/ruby/test_gc_compact.rb @@ -69,10 +69,11 @@ def test_implicit_compaction_does_something } count = GC.stat :compact_count GC.auto_compact = true - loop do + n = 1_000_000 + n.times do break if count < GC.stat(:compact_count) list2 << Object.new - end + end and skip "implicit compaction didn't happen within #{n} objects" compact_stats = GC.latest_compact_info refute_predicate compact_stats[:considered], :empty? refute_predicate compact_stats[:moved], :empty?