File tree Expand file tree Collapse file tree 1 file changed +22
-0
lines changed Expand file tree Collapse file tree 1 file changed +22
-0
lines changed Original file line number Diff line number Diff line change @@ -402,6 +402,28 @@ def test_expand_heap
402
402
eom
403
403
end
404
404
405
+ def test_thrashing_for_young_objects
406
+ # This test prevents bugs like [Bug #18929]
407
+
408
+ assert_separately %w[ --disable-gem ] , __FILE__ , __LINE__ , <<-RUBY
409
+ # Warmup to make sure heap stabilizes
410
+ 1_000_000.times { Object.new }
411
+
412
+ before_stats = GC.stat
413
+
414
+ 1_000_000.times { Object.new }
415
+
416
+ after_stats = GC.stat
417
+
418
+ # Should not be thrashing in page creation
419
+ assert_equal before_stats[:heap_allocated_pages], after_stats[:heap_allocated_pages]
420
+ assert_equal 0, after_stats[:heap_tomb_pages]
421
+ assert_equal 0, after_stats[:total_freed_pages]
422
+ # Only young objects, so should not trigger major GC
423
+ assert_equal before_stats[:major_gc_count], after_stats[:major_gc_count]
424
+ RUBY
425
+ end
426
+
405
427
def test_gc_internals
406
428
assert_not_nil GC ::INTERNAL_CONSTANTS [ :HEAP_PAGE_OBJ_LIMIT ]
407
429
assert_not_nil GC ::INTERNAL_CONSTANTS [ :RVALUE_SIZE ]
You can’t perform that action at this time.
0 commit comments