I'm pleased to announce to new libraries written by members of the Seattle Ruby Brigade, mem_inspect and png!
mem_inspect is ObjectSpace.each_object on crack. mem_inspect gives you the contents of each slot in Ruby's heap. mem_inspect also includes viewers that let you visualize the contents of Ruby's heap.
$ sudo gem install mem_inspect
Then you'll need to build a patched ruby:
You'll then have a ruby capable of running mem_inspect in mem_inspect_ruby_1_8.
You can make an image with:
mem_inspect_ruby_1_8/ruby_mem_inspect -S ruby_mem_dump
Which will give you a PNG in your current directory named:
You'll get an image that looks something like this:
To dump a PDF any time you want:
You can also dump to an AquaTerm plot window if you have RubyCocoa and AquaTerm installed.
png is a pure-ruby PNG writing library written by Ryan Davis.
$ sudo gem install png
canvas = PNG::Canvas.new 200, 200
# Set a point to a color
canvas[100, 100] = PNG::Color::Black
# draw an anti-aliased line
canvas.line 50, 50, 100, 50, PNG::Color::Blue
png = PNG.new canvas