End of Life Ruby 3.2 has reached end of life and gets no more fixes. Switch to Ruby 4.0 →
instance method
ObjectSpace#dump_shapes
ObjectSpace.dump_shapes([output: :file]) → #<File:/tmp/rubyshapes20131125-88469-laoj3v.json>
ObjectSpace.dump_shapes(output: :stdout) → nil
ObjectSpace.dump_shapes(output: :string) → "{...}\n{...}\n..."
ObjectSpace.dump_shapes(output: File.open('shapes.json','w')) → #<File:shapes.json>
ObjectSpace.dump_all(output: :string, since: 42) → "{...}\n{...}\n..."
ext/objspace/lib/objspace.rb
View on GitHub ↗
# File tmp/rubies/ruby-3.2.0/ext/objspace/lib/objspace.rb, line 123
def dump_shapes(output: :file, since: 0)
out = case output
when :file, nil
require 'tempfile'
Tempfile.create(%w(rubyshapes .json))
when :stdout
STDOUT
when :string
+''
when IO
output
else
raise ArgumentError, "wrong output option: #{output.inspect}"
end
ret = _dump_shapes(out, since)
return nil if output == :stdout
ret
end
Dump the contents of the ruby shape tree as JSON.
If shapes is a positive integer, only shapes newer than the provided shape id are dumped. The current shape_id can be accessed using RubyVM.stat(:next_shape_id).
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.