~kb/dumpster

Fast memory dump analysis for Ruby.
docs(readme): prune
fix(LICENSE): update copyright holder reference
6a310c8b — Kim Burgess 2 years ago
doc(readme): add usage instructions

refs

main
browse  log 

clone

read-only
https://git.sr.ht/~kb/dumpster
read/write
git@git.sr.ht:~kb/dumpster

You can also use your local clone with git send-email.

#Dumpster

An analysis tool for Ruby MRI heap dumps.

Provides automated analysis and identification of potential memory leaks within a program.

#Usage

#Capturing Heap Dumps

Using rbtrace, enable allocation tracking on the ruby process you'd like to inspect. Note: this will result in a perf impact while active. Use with care.

rbtrace -p <pid> -e 'Thread.new{require "objspace";ObjectSpace.trace_object_allocations_start}.join'

After the process has had time to rotate through a few GC generations, export via:

rbtrace -p <pid> -e 'Thread.new{require "objspace";io=File.open("/tmp/ruby-heap.dump", "w");ObjectSpace.dump_all(output: io);io.close}.join'

To stop tracking and clear allocations from mem:

rbtrace -p <pid> -e 'Thread.new{GC.start;require "objspace";ObjectSpace.trace_object_allocations_stop;ObjectSpace.trace_object_allocations_clear}.join'

#Analysis

!! When using outside of a dev context, analysis should always take place on a machine remote to that running the application under analysis.

./dumpster ruby-heap.dump

Depending on the size of heap dump being parsed, analysis may take some time. Progress will be provided. When complete, a ordered list of 'locations of interest' will be provided. These are lines responsible for an increasing number of long-lived object allocations that may be indicative of a memory leak.