Preview Ruby 4.1 is a preview. It can change before the final release. Switch to Ruby 4.0 →
class method
ObjectSpace.count_imemo_objects
(?::Hash[::Symbol, ::Integer] result_hash) -> ::Hash[::Symbol, ::Integer]
ObjectSpace.count_imemo_objects(result_hash = nil) → hash
ext/objspace/objspace.c
View on GitHub ↗
static VALUE
count_imemo_objects(int argc, VALUE *argv, VALUE self)
{
VALUE hash = setup_hash(argc, argv);
if (imemo_type_ids[0] == 0) {
#define INIT_IMEMO_TYPE_ID(n) (imemo_type_ids[n] = rb_intern_const(#n))
INIT_IMEMO_TYPE_ID(imemo_env);
INIT_IMEMO_TYPE_ID(imemo_cref);
INIT_IMEMO_TYPE_ID(imemo_svar);
INIT_IMEMO_TYPE_ID(imemo_throw_data);
INIT_IMEMO_TYPE_ID(imemo_ifunc);
INIT_IMEMO_TYPE_ID(imemo_memo);
INIT_IMEMO_TYPE_ID(imemo_ment);
INIT_IMEMO_TYPE_ID(imemo_iseq);
INIT_IMEMO_TYPE_ID(imemo_tmpbuf);
INIT_IMEMO_TYPE_ID(imemo_cvar_entry);
INIT_IMEMO_TYPE_ID(imemo_callinfo);
INIT_IMEMO_TYPE_ID(imemo_callcache);
INIT_IMEMO_TYPE_ID(imemo_constcache);
INIT_IMEMO_TYPE_ID(imemo_fields);
INIT_IMEMO_TYPE_ID(imemo_subclasses);
INIT_IMEMO_TYPE_ID(imemo_cdhash);
#undef INIT_IMEMO_TYPE_ID
}
each_object_with_flags(count_imemo_objects_i, (void *)hash);
return hash;
}
Returns a hash containing the number of objects for each T_IMEMO type. The keys are Symbol objects of the T_IMEMO type name. T_IMEMO objects are Ruby internal objects that are not visible to Ruby programs.
Example
ObjectSpace.count_imemo_objects # => {imemo_callcache: 5482, imemo_constcache: 1258, imemo_ment: 13906, ... }
If the optional argument result_hash is given, it is overwritten and returned. This is intended to avoid the probe effect.
This method is intended for developers interested in performance and memory usage of Ruby programs. The contents of the returned hash is implementation specific and may change in the future.
This method is only expected to work with C Ruby.
See also
.allocation_sourceline
.count_objects
.allocation_sourcefile
.count_objects_size
also in
4.0 · 3.4 · 3.3 · 3.2 · 3.1 · 3.0