ruby-changes:36765
From: ko1 <ko1@a...>
Date: Mon, 15 Dec 2014 17:54:26 +0900 (JST)
Subject: [ruby-changes:36765] ko1:r48846 (trunk): * ext/objspace/objspace.c: ObjectSpace.memsize_of(obj) returns
ko1 2014-12-15 17:54:07 +0900 (Mon, 15 Dec 2014) New Revision: 48846 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=48846 Log: * 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. Modified files: trunk/ChangeLog trunk/NEWS trunk/ext/objspace/objspace.c trunk/gc.c trunk/test/objspace/test_objspace.rb trunk/test/ruby/test_file_exhaustive.rb Index: ChangeLog =================================================================== --- ChangeLog (revision 48845) +++ ChangeLog (revision 48846) @@ -1,3 +1,16 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1 +Mon Dec 15 17:51:28 2014 Koichi Sasada <ko1@a...> + + * 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@r...> * string.c (rb_enc_str_coderange): dummy wchar, non-endianness Index: gc.c =================================================================== --- gc.c (revision 48845) +++ gc.c (revision 48846) @@ -2941,7 +2941,7 @@ obj_memsize_of(VALUE obj, int use_all_ty https://github.com/ruby/ruby/blob/trunk/gc.c#L2941 BUILTIN_TYPE(obj), (void*)obj); } - return size; + return size + sizeof(RVALUE); } size_t Index: ext/objspace/objspace.c =================================================================== --- ext/objspace/objspace.c (revision 48845) +++ ext/objspace/objspace.c (revision 48846) @@ -30,6 +30,9 @@ https://github.com/ruby/ruby/blob/trunk/ext/objspace/objspace.c#L30 * 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 Index: NEWS =================================================================== --- NEWS (revision 48845) +++ NEWS (revision 48846) @@ -243,6 +243,10 @@ with all sufficient information, see the https://github.com/ruby/ruby/blob/trunk/NEWS#L243 * 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 Index: test/ruby/test_file_exhaustive.rb =================================================================== --- test/ruby/test_file_exhaustive.rb (revision 48845) +++ test/ruby/test_file_exhaustive.rb (revision 48846) @@ -461,9 +461,9 @@ class TestFileExhaustive < Test::Unit::T https://github.com/ruby/ruby/blob/trunk/test/ruby/test_file_exhaustive.rb#L461 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 Index: test/objspace/test_objspace.rb =================================================================== --- test/objspace/test_objspace.rb (revision 48845) +++ test/objspace/test_objspace.rb (revision 48846) @@ -28,7 +28,8 @@ class TestObjSpace < Test::Unit::TestCas https://github.com/ruby/ruby/blob/trunk/test/objspace/test_objspace.rb#L28 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 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/