Skip to content

Instantly share code, notes, and snippets.

@csavage-mdsol
Created November 12, 2014 18:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save csavage-mdsol/8e1bd423deac5be8f75f to your computer and use it in GitHub Desktop.
Save csavage-mdsol/8e1bd423deac5be8f75f to your computer and use it in GitHub Desktop.
rbtrace JSON Heap Dump
# Provide the PID of a running rails process, and dump the heap to heap.json
# WARNING these can get pretty huge (~100MB)
# requries ruby 2.1 for shiny new ObjectSpace features
rbtrace -p <PID> -e 'Thread.new{require "objspace"; ObjectSpace.trace_object_allocations_start; GC.start(); ObjectSpace.dump_all(output: File.open("heap.json", "w"))}.join'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment