diff options
author | yugui <yugui@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2010-10-23 12:50:53 +0000 |
---|---|---|
committer | yugui <yugui@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2010-10-23 12:50:53 +0000 |
commit | 1e90b4a852bc8c3211ca673cf7230ce824460062 (patch) | |
tree | 2ad7db650e5a884fb2921a700e2ff7bac99c6ef3 | |
parent | d9cd722638146ace80396e32a0d74a42893a8015 (diff) |
merges r28986 from trunk into ruby_1_9_2. fixes [ruby-core:32667]
--
* test/objspace/test_objspace.rb: added test for objspace.
* ext/objspace/objspace.c: considers T_ZOMBIE by lazy sweep GC.
* gc.c: considers that dsize was 0. [ruby-dev:42022]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_9_2@29570 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r-- | ChangeLog | 8 | ||||
-rw-r--r-- | ext/objspace/objspace.c | 3 | ||||
-rw-r--r-- | gc.c | 2 | ||||
-rw-r--r-- | test/objspace/test_objspace.rb | 44 | ||||
-rw-r--r-- | version.h | 2 |
5 files changed, 57 insertions, 2 deletions
@@ -1,3 +1,11 @@ +Sat Aug 14 17:48:41 2010 Narihiro Nakamura <authorNari@gmail.com> + + * test/objspace/test_objspace.rb: added test for objspace. + + * ext/objspace/objspace.c: considers T_ZOMBIE by lazy sweep GC. + + * gc.c: considers that dsize was 0. [ruby-dev:42022] + Tue Aug 31 03:42:14 2010 NARUSE, Yui <naruse@ruby-lang.org> * string.c (tr_setup_table): fix bug in r29146. diff --git a/ext/objspace/objspace.c b/ext/objspace/objspace.c index 817380f83c..ebca2f8487 100644 --- a/ext/objspace/objspace.c +++ b/ext/objspace/objspace.c @@ -141,6 +141,9 @@ memsize_of(VALUE obj) } break; + case T_ZOMBIE: + break; + default: rb_bug("objspace/memsize_of(): unknown data type 0x%x(%p)", BUILTIN_TYPE(obj), (void*)obj); @@ -1145,7 +1145,7 @@ rb_data_typed_object_alloc(VALUE klass, void *datap, const rb_data_type_t *type) size_t rb_objspace_data_type_memsize(VALUE obj) { - if (RTYPEDDATA_P(obj)) { + if (RTYPEDDATA_P(obj) && RTYPEDDATA_TYPE(obj)->dsize) { return RTYPEDDATA_TYPE(obj)->dsize(RTYPEDDATA_DATA(obj)); } else { diff --git a/test/objspace/test_objspace.rb b/test/objspace/test_objspace.rb new file mode 100644 index 0000000000..cfdb485747 --- /dev/null +++ b/test/objspace/test_objspace.rb @@ -0,0 +1,44 @@ +require "test/unit" +require "objspace" + +class TestObjSpace < Test::Unit::TestCase + def test_memsize_of + assert_equal(0, ObjectSpace.memsize_of(true)) + assert_kind_of(Integer, ObjectSpace.memsize_of(Object.new)) + assert_kind_of(Integer, ObjectSpace.memsize_of(Class)) + assert_kind_of(Integer, ObjectSpace.memsize_of("")) + assert_kind_of(Integer, ObjectSpace.memsize_of([])) + assert_kind_of(Integer, ObjectSpace.memsize_of({})) + assert_kind_of(Integer, ObjectSpace.memsize_of(//)) + f = File.new(__FILE__) + assert_kind_of(Integer, ObjectSpace.memsize_of(f)) + f.close + assert_kind_of(Integer, ObjectSpace.memsize_of(/a/.match("a"))) + assert_kind_of(Integer, ObjectSpace.memsize_of(Struct.new(:a))) + end + + def test_count_objects_size + res = ObjectSpace.count_objects_size + assert_equal(false, res.empty?) + assert_equal(true, res[:TOTAL] > 0) + arg = {} + ObjectSpace.count_objects_size(arg) + assert_equal(false, arg.empty?) + end + + def test_count_nodes + res = ObjectSpace.count_nodes + assert_equal(false, res.empty?) + arg = {} + ObjectSpace.count_nodes(arg) + assert_equal(false, arg.empty?) + end + + def test_count_tdata_objects + res = ObjectSpace.count_tdata_objects + assert_equal(false, res.empty?) + arg = {} + ObjectSpace.count_tdata_objects(arg) + assert_equal(false, arg.empty?) + end +end @@ -1,5 +1,5 @@ #define RUBY_VERSION "1.9.2" -#define RUBY_PATCHLEVEL 23 +#define RUBY_PATCHLEVEL 24 #define RUBY_VERSION_MAJOR 1 #define RUBY_VERSION_MINOR 9 #define RUBY_VERSION_TEENY 1 |