Skip to content

End of Life Ruby 3.0 has reached end of life and gets no more fixes. Switch to Ruby 4.0 →

instance method

ObjectSpace#dump_all

ObjectSpace.dump_all([output: :file]) # => #<File:/tmp/rubyheap20131125-88469-laoj3v.json>
ObjectSpace.dump_all(output: :stdout) # => nil
ObjectSpace.dump_all(output: :string) # => "{...}\n{...}\n..."
ObjectSpace.dump_all(output:
File.open('heap.json','w')) # => #<File:heap.json>
ObjectSpace.dump_all(output: :string,
since: 42) # => "{...}\n{...}\n..."

Dump the contents of the ruby heap as JSON.

since must be a non-negative integer or nil.

If since is a positive integer, only objects of that generation and newer generations are dumped. The current generation can be accessed using GC::count.

Objects that were allocated without object allocation tracing enabled are ignored. See ::trace_object_allocations for more information and examples.

If since is omitted or is nil, all objects are dumped.

This method is only expected to work with C Ruby. This is an experimental method and is subject to change. In particular, the function signature and output format are not guaranteed to be compatible in future versions of ruby.

See also #dump #garbage_collect .undefine_finalizer also in 4.1 · 4.0 · 3.4 · 3.3 · 3.2 · 3.1