class method
ObjectSpace.trace_object_allocations
() { (untyped) -> untyped } -> untyped
trace_object_allocations { block }
ext/objspace/object_tracing.c
View on GitHub ↗
static VALUE
trace_object_allocations(VALUE self)
{
trace_object_allocations_start(self);
return rb_ensure(rb_yield, Qnil, trace_object_allocations_stop, self);
}
Starts tracing object allocations from the ObjectSpace extension module.
For example:
Example
require 'objspace' class C include ObjectSpace def foo trace_object_allocations do obj = Object.new p "#{allocation_sourcefile(obj)}:#{allocation_sourceline(obj)}" end end end C.new.foo #=> "objtrace.rb:8"
This example has included the ObjectSpace module to make it easier to read, but you can also use the ::trace_object_allocations notation (recommended).
Note that this feature introduces a huge performance decrease and huge memory consumption.
See also
.reachable_objects_from_root
.trace_object_allocations_clear
.reachable_objects_from
.trace_object_allocations_debug_start
also in
4.1 · 3.4 · 3.3 · 3.2 · 3.1 · 3.0