1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

* ext/objspace/objspace.c: support ObjectSpace.trace_object_allocations.

Read the following test to know HOWTO.
  This feature is a sample of RUBY_INTERNAL_EVENT.
* test/objspace/test_objspace.rb: add a test.
* ext/objspace/object_tracing.c: ditto.
* gc.c (rb_gc_count): add. THis function returns GC count.
* internal.h: add decl. of rb_gc_count(). Same as `GC.count'.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40957 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
ko1 2013-05-27 10:01:45 +00:00
parent 14f6c8ca8a
commit 050dd10d6f
6 changed files with 242 additions and 1 deletions

View file

@ -108,4 +108,22 @@ class TestObjSpace < Test::Unit::TestCase
}
eom
end
def test_traceobject
o0 = Object.new
ObjectSpace.trace_object_allocations{
o1 = Object.new; line1 = __LINE__
o2 = "a"+"b" ; line2 = __LINE__
o3 = [1, 2] ; line3 = __LINE__
assert_equal(nil, ObjectSpace.allocation_sourcefile(o0))
assert_equal(nil, ObjectSpace.allocation_sourceline(o0))
assert_equal(__FILE__, ObjectSpace.allocation_sourcefile(o1))
assert_equal(line1, ObjectSpace.allocation_sourceline(o1))
assert_equal(__FILE__, ObjectSpace.allocation_sourcefile(o2))
assert_equal(line2, ObjectSpace.allocation_sourceline(o2))
assert_equal(__FILE__, ObjectSpace.allocation_sourcefile(o3))
assert_equal(line3, ObjectSpace.allocation_sourceline(o3))
}
end
end