From 523a6998dd45eb910ccd3fe6a8d9d008f7a12cf2 Mon Sep 17 00:00:00 2001 From: Koichi Sasada Date: Wed, 12 May 2021 17:35:57 +0900 Subject: Use another class for the comparison. `memsize_of(Object.new)` can be changed with past ivar creation history for Object instances (another Object instance has 4 or more ivars, next created Object instance has the area for the ivars). So use antoher class for the comparison. --- test/objspace/test_objspace.rb | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/test/objspace/test_objspace.rb b/test/objspace/test_objspace.rb index 812b0817a8..8a0b6fba20 100644 --- a/test/objspace/test_objspace.rb +++ b/test/objspace/test_objspace.rb @@ -106,10 +106,9 @@ class TestObjSpace < Test::Unit::TestCase end def test_memsize_of_iseq - skip # To debug - iseqw = RubyVM::InstructionSequence.compile('def a; a = :b; a; end') - base_obj_size = ObjectSpace.memsize_of(Object.new) + # Use anonymous class as a basic object size because size of Object.new can be increased + base_obj_size = ObjectSpace.memsize_of(Class.new.new) assert_operator(ObjectSpace.memsize_of(iseqw), :>, base_obj_size) end -- cgit v1.2.3