Paul Engel, whose CSONV we covered previously, has created Ruby Mass, a gem that helps you introspect the Ruby heap. Ruby Mass indexes, counts, and locates object references.

$ Mass.index Foo #=> {}

$ f = Foo.new
$ b1 = Foo::Bar.new
$ b2 = Foo::Bar.new
$ t = Thing.new

$ f.object_id #=> 2154166500
$ b1.object_id #=> 2154037400
$ b2.object_id #=> 2154126780
$ t.object_id #=> 2154372180

$ Mass.index Foo #=> {"Foo"=>[2154166500], "Foo::Bar"=>[2154037400, 2154126780]}
$ Mass.index Foo::Bar #=> {"Foo::Bar"=>[2154037400, 2154126780]}
$ Mass.index Thing #=> {"Thing"=>[2154372180]}
$ Mass.index #=> {"String"=>[2151797000, 2151797080, 2151797120, 2151797140, ... a lot of more classes and object_ids}
$ Mass.index OneMoreThing #=> {}

As always, check the README for usage. The source is on GitHub.


Have comments? Send a tweet to @TheChangelog on Twitter.

Subscribe to The Changelog Weekly – our weekly email covering everything that hits our open source radar.