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.

Overloads:

  • .dump_all([output: :file]) ⇒ #<File:/tmp/rubyheap20131125-88469-laoj3v.json

    Returns ].

    Returns:

    • (#<File:/tmp/rubyheap20131125-88469-laoj3v.json)

      ]

  • .dump_all(output: :stdout) ⇒ nil

    Returns:

    • (nil)
  • .open('heap.json', 'w') ⇒ #<File:heap.json

    Returns ].

    Returns:

    • (#<File:heap.json)

      ]



441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
# File 'objspace_dump.c', line 441

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);
}