DOKK / manpages / debian 11 / ruby-heapy / heapy.1.en
HEAPY(1) General Commands Manual HEAPY(1)

heapy - CLI for analyzing Ruby Heap dumps

heapy read [file|command] [number|all]

heapy is a CLI for analyzing Heap dumps in Ruby. Start analyzing heap dumps of a command or files by:

$ heapy read [file|command]
Dumps from Ruby command can be analyzed by,
$ heapy read <command>
Heap dumps from files can also be analayzed,
$ heapy read file.dump


Generation: nil object count: 209191
Generation: 18 object count: 805

NOTE: The reason of getting a "nil" generation is these objects were loaded into memory before your code began tracking the allocations. To ensure all allocations are tracked one should execute the ruby script this trick.

First create a file trace.rb that only starts allocation tracing:

require ´objspace´

ObjectSpace.trace_object_allocations_start

Now make sure this command is loaded before running the script, use Ruby´s -I to specify a load path and -r to specify a library to require, in this case the trace file,
$ ruby -I ./ -r trace script_name.rb
If the last line of file is invalid JSON, make sure that file is closed file after writing the ruby heap dump to it.

To analyze a specific generation, pass the generation number along with the command. For example, to analyze 17th generation in file.dump,

$ heapy read file.dump 17
To get all generations pass "all" directive
$ heapy read file.dump all

Heapy was written by Richard Schneeman. Initial code and idea was developed by Sam Saffron.

September 2018