Method: ObjectSpace.dump_all
- Defined in:
- objspace_dump.c
.dump_all([output: :file]) ⇒ #<File:/tmp/rubyheap20131125-88469-laoj3v.json .dump_all(output: :stdout) ⇒ nil .dump_all(output: :string) ⇒ Object .dump_all(output: ) ⇒ Object .open('heap.json', 'w') ⇒ #<File:heap.json
Dump the contents of the ruby heap as JSON.
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.
394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 |
# File 'objspace_dump.c', line 394
static VALUE
objspace_dump_all(int argc, VALUE *argv, VALUE os)
{
static const char filename[] = "rubyheap";
VALUE opts = Qnil, output;
struct dump_config dc = {0,};
rb_scan_args(argc, argv, "0:", &opts);
output = dump_output(&dc, opts, sym_file, filename);
/* dump roots */
rb_objspace_reachable_objects_from_root(root_obj_i, &dc);
if (dc.roots) dump_append(&dc, "]}\n");
/* dump all objects */
rb_objspace_each_objects(heap_i, &dc);
return dump_result(&dc, output);
}
|