From 907a03fee52b06760cec2d6fbd0dd2e693bef970 Mon Sep 17 00:00:00 2001 From: tmm1 Date: Fri, 4 Oct 2013 10:05:40 +0000 Subject: gc.c: add objspace_free_num and make GC.stat[:heap_free_num] use it * gc.c (objspace_free_num): new method for available/free slots on heap. [ruby-core:57633] [Bug #8983] * gc.c (gc_stat): change heap_free_num definition to use new method. * test/ruby/test_gc.rb: test for above. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43139 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- test/ruby/test_gc.rb | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'test/ruby') diff --git a/test/ruby/test_gc.rb b/test/ruby/test_gc.rb index 53fd107747..30baebb67a 100644 --- a/test/ruby/test_gc.rb +++ b/test/ruby/test_gc.rb @@ -70,6 +70,13 @@ class TestGc < Test::Unit::TestCase GC.stat(stat) ObjectSpace.count_objects(count) assert_equal(count[:TOTAL]-count[:FREE], stat[:heap_live_num]) + assert_equal(count[:FREE], stat[:heap_free_num]) + + # measure again without GC.start + 1000.times{ "a" + "b" } + GC.stat(stat) + ObjectSpace.count_objects(count) + assert_equal(count[:FREE], stat[:heap_free_num]) end def test_singleton_method -- cgit v1.2.3