End of Life Ruby 3.2 has reached end of life and gets no more fixes. Switch to Ruby 4.0 →
class method
ObjectSpace.memsize_of
ObjectSpace.memsize_of(obj) → Integer
ext/objspace/objspace.c
View on GitHub ↗
static VALUE
memsize_of_m(VALUE self, VALUE obj)
{
return SIZET2NUM(rb_obj_memsize_of(obj));
}
Return consuming memory size of obj in bytes.
Note that the return size is incomplete. You need to deal with this information as only a HINT. Especially, the size of T_DATA may not be 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).
See also
.internal_super_of
.memsize_of_all
.internal_class_of
.reachable_objects_from
also in
4.1 · 4.0 · 3.4 · 3.3 · 3.1 · 3.0