Skip to content

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

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.