Method: ObjectSpace.memsize_of

Defined in:
objspace.c

.memsize_of(obj) ⇒ Integer

Return consuming memory size of obj.

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).

Returns:

  • (Integer)


38
39
40
41
42
# File 'objspace.c', line 38

static VALUE
memsize_of_m(VALUE self, VALUE obj)
{
    return SIZET2NUM(rb_obj_memsize_of(obj));
}