diff options
author | ko1 <ko1@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2014-12-15 08:54:07 +0000 |
---|---|---|
committer | ko1 <ko1@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2014-12-15 08:54:07 +0000 |
commit | 85b42fe17b67688143e26f72b47aad766744ac3a (patch) | |
tree | 9864b5902447cf8e99d62888663e8dc99347ef08 | |
parent | 020fcc95fe948f65b03609d445a6cf1bc0c06dc5 (diff) | |
download | ruby-85b42fe17b67688143e26f72b47aad766744ac3a.tar.gz |
* ext/objspace/objspace.c: ObjectSpace.memsize_of(obj) returns
with sizeof(RVALUE). [Bug #8984]
* gc.c (obj_memsize_of): ditto.
* NEWS: add a NEWS entry.
* test/objspace/test_objspace.rb: catch up this fix.
* test/ruby/test_file_exhaustive.rb: ditto.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48846 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r-- | ChangeLog | 13 | ||||
-rw-r--r-- | NEWS | 4 | ||||
-rw-r--r-- | ext/objspace/objspace.c | 3 | ||||
-rw-r--r-- | gc.c | 2 | ||||
-rw-r--r-- | test/objspace/test_objspace.rb | 3 | ||||
-rw-r--r-- | test/ruby/test_file_exhaustive.rb | 4 |
6 files changed, 25 insertions, 4 deletions
@@ -1,3 +1,16 @@ +Mon Dec 15 17:51:28 2014 Koichi Sasada <ko1@atdot.net> + + * ext/objspace/objspace.c: ObjectSpace.memsize_of(obj) returns + with sizeof(RVALUE). [Bug #8984] + + * gc.c (obj_memsize_of): ditto. + + * NEWS: add a NEWS entry. + + * test/objspace/test_objspace.rb: catch up this fix. + + * test/ruby/test_file_exhaustive.rb: ditto. + Mon Dec 15 16:19:23 2014 Nobuyoshi Nakada <nobu@ruby-lang.org> * string.c (rb_enc_str_coderange): dummy wchar, non-endianness @@ -243,6 +243,10 @@ with all sufficient information, see the ChangeLog file. * Logger * Logger::Application is extracted to logger-application gem. It's unmaintain code. +* ObjectSpace (after requiring "objspace") + * ObjectSpace.memsize_of(obj) returns a size includes sizeof(RVALUE). + [Bug #8984] + * Prime * incompatible changes: * Prime.prime? now returns false for negative numbers. This method diff --git a/ext/objspace/objspace.c b/ext/objspace/objspace.c index bc02e579cd..038461a394 100644 --- a/ext/objspace/objspace.c +++ b/ext/objspace/objspace.c @@ -30,6 +30,9 @@ * correct. * * This method is only expected to work with C Ruby. + * + * From Ruby 2.2, memsize_of(obj) returns a memory size includes + * sizeof(RVALUE). */ static VALUE @@ -2941,7 +2941,7 @@ obj_memsize_of(VALUE obj, int use_all_types) BUILTIN_TYPE(obj), (void*)obj); } - return size; + return size + sizeof(RVALUE); } size_t diff --git a/test/objspace/test_objspace.rb b/test/objspace/test_objspace.rb index f507562b80..66a8a1683b 100644 --- a/test/objspace/test_objspace.rb +++ b/test/objspace/test_objspace.rb @@ -28,7 +28,8 @@ class TestObjSpace < Test::Unit::TestCase b = a.dup c = nil ObjectSpace.each_object(String) {|x| break c = x if x == a and x.frozen?} - assert_equal([0, 0, 26], [a, b, c].map {|x| ObjectSpace.memsize_of(x)}) + rv_size = GC::INTERNAL_CONSTANTS[:RVALUE_SIZE] + assert_equal([rv_size, rv_size, 26 + rv_size], [a, b, c].map {|x| ObjectSpace.memsize_of(x)}) end def test_argf_memsize diff --git a/test/ruby/test_file_exhaustive.rb b/test/ruby/test_file_exhaustive.rb index 59ed117db8..af66b68123 100644 --- a/test/ruby/test_file_exhaustive.rb +++ b/test/ruby/test_file_exhaustive.rb @@ -461,9 +461,9 @@ class TestFileExhaustive < Test::Unit::TestCase bug9934 = '[ruby-core:63114] [Bug #9934]' require "objspace" path = File.expand_path("/foo") - assert_operator(ObjectSpace.memsize_of(path), :<=, path.bytesize, bug9934) + assert_operator(ObjectSpace.memsize_of(path), :<=, path.bytesize + GC::INTERNAL_CONSTANTS[:RVALUE_SIZE], bug9934) path = File.expand_path("/a"*25) - assert_equal(path.bytesize+1, ObjectSpace.memsize_of(path), bug9934) + assert_equal(path.bytesize+1 + GC::INTERNAL_CONSTANTS[:RVALUE_SIZE], ObjectSpace.memsize_of(path), bug9934) end def test_expand_path_encoding |