* ext/objspace/objspace.c (iow_size): return size of internal object
for ObjectSpace.memsize_of(). * test/objspace/test_objspace.rb: add a test. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38266 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
5b1065f3fe
commit
1c5b309211
@ -1,3 +1,10 @@
|
|||||||
|
Sat Dec 8 07:57:12 2012 Koichi Sasada <ko1@atdot.net>
|
||||||
|
|
||||||
|
* ext/objspace/objspace.c (iow_size): return size of internal object
|
||||||
|
for ObjectSpace.memsize_of().
|
||||||
|
|
||||||
|
* test/objspace/test_objspace.rb: add a test.
|
||||||
|
|
||||||
Tue Dec 08 02:39:23 2012 James Edward Gray II <james@graysoftinc.com>
|
Tue Dec 08 02:39:23 2012 James Edward Gray II <james@graysoftinc.com>
|
||||||
|
|
||||||
* lib/csv.rb: A fix for row comparison by Stephen Wattam. [Bug #7528]
|
* lib/csv.rb: A fix for row comparison by Stephen Wattam. [Bug #7528]
|
||||||
|
@ -639,9 +639,16 @@ iow_mark(void *ptr)
|
|||||||
rb_gc_mark((VALUE)ptr);
|
rb_gc_mark((VALUE)ptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static size_t
|
||||||
|
iow_size(const void *ptr)
|
||||||
|
{
|
||||||
|
VALUE obj = (VALUE)ptr;
|
||||||
|
return memsize_of(obj);
|
||||||
|
}
|
||||||
|
|
||||||
static const rb_data_type_t iow_data_type = {
|
static const rb_data_type_t iow_data_type = {
|
||||||
"ObjectSpace::InternalObjectWrapper",
|
"ObjectSpace::InternalObjectWrapper",
|
||||||
{iow_mark, 0, 0,},
|
{iow_mark, 0, iow_size,},
|
||||||
};
|
};
|
||||||
|
|
||||||
static VALUE rb_mInternalObjectWrapper;
|
static VALUE rb_mInternalObjectWrapper;
|
||||||
|
@ -92,4 +92,14 @@ class TestObjSpace < Test::Unit::TestCase
|
|||||||
}
|
}
|
||||||
assert_operator(max, :>=, 1_001, "1000 elems + Array class")
|
assert_operator(max, :>=, 1_001, "1000 elems + Array class")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_reachable_objects_size
|
||||||
|
ObjectSpace.each_object{|o|
|
||||||
|
ObjectSpace.reachable_objects_from(o).each{|reached_obj|
|
||||||
|
size = ObjectSpace.memsize_of(reached_obj)
|
||||||
|
assert_kind_of(Integer, size)
|
||||||
|
assert_operator(size, :>=, 0)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
Loading…
x
Reference in New Issue
Block a user