diff options
author | tmm1 <tmm1@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2013-11-28 07:40:35 +0000 |
---|---|---|
committer | tmm1 <tmm1@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2013-11-28 07:40:35 +0000 |
commit | d7009f76ef8a7b96e73471561cf9c4863902e438 (patch) | |
tree | eced005e9132a64eb1d6c61c9dbe8bd8ef41e7f1 /test | |
parent | 6de07f1fbe1e2819ac625c6b64069f54033b0164 (diff) |
* gc.c: Expose details about last garbage collection via GC.stat.
* gc.c (gc_stat): Add :last_collection_flags for reason/trigger/type of
last GC run.
* gc.c (gc_prof_sweep_timer_stop): Record HAVE_FINALIZE GPR even
without GC_PROFILE_MORE_DETAIL.
* gc.c (gc_profile_flags): Add GC::Profiler.decode_flags to make sense
of GC.stat[:last_collection_flags]
* test/ruby/test_gc.rb (class TestGc): Test for above.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43893 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test')
-rw-r--r-- | test/ruby/test_gc.rb | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/test/ruby/test_gc.rb b/test/ruby/test_gc.rb index 0d101f609b..2668582ed8 100644 --- a/test/ruby/test_gc.rb +++ b/test/ruby/test_gc.rb @@ -79,6 +79,26 @@ class TestGc < Test::Unit::TestCase assert_equal(count[:FREE], stat[:heap_free_slot]) end + def test_gc_reason + 100_000.times{ "a" + "b" } + assert_equal({:gc_by => :newobj}, + GC::Profiler.decode_flags(GC.stat[:last_collection_flags])) + end + + def test_gc_reason_method + GC.start + assert_equal({:major_by=>:nofree, :gc_by=>:method, :immediate_sweep=>true}, + GC::Profiler.decode_flags(GC.stat[:last_collection_flags])) + end + + def test_gc_reason_stress + GC.stress = true + assert_equal({:major_by=>:stress, :gc_by=>:malloc, :immediate_sweep=>true}, + GC::Profiler.decode_flags(GC.stat[:last_collection_flags])) + ensure + GC.stress = false + end + def test_singleton_method assert_in_out_err(%w[--disable-gems], <<-EOS, [], [], "[ruby-dev:42832]") GC.stress = true |