Method: ObjectSpace.count_tdata_objects
- Defined in:
- objspace.c
.count_tdata_objects([result_hash]) ⇒ Hash
Counts objects for each T_DATA type.
This method is only for MRI developers interested in performance and memory usage of Ruby programs.
It returns a hash as:
:parser=>5, :barrier=>6, :mutex=>6, Proc=>60, RubyVM::Env=>57, Mutex=>1, Encoding=>99, ThreadGroup=>1, Binding=>1, Thread=>1, RubyVM=>1, :iseq=>1, Random=>1, ARGF.class=>1, Data=>1, :autoload=>3, Time=>2 # T_DATA objects existing at startup on r32276.
If the optional argument, result_hash, is given, it is overwritten and returned. This is intended to avoid probe effect.
The contents of the returned hash is implementation specific and may change in the future.
In this version, keys are Class object or Symbol object.
If object is kind of normal (accessible) object, the key is Class object. If object is not a kind of normal (internal) object, the key is symbol name, registered by rb_data_type_struct.
This method is only expected to work with C Ruby.
574 575 576 577 578 579 580 |
# File 'objspace.c', line 574 static VALUE count_tdata_objects(int argc, VALUE *argv, VALUE self) { VALUE hash = setup_hash(argc, argv); each_object_with_flags(cto_i, (void *)hash); return hash; } |