How to Install a Patched Ruby Interpreter With Rbenv and Ruby-build

A background scheduled task I am trying to run on heroku is failing because it gets out of memory. I needed to use a ruby memory profiler to understand exactly what the issue was. ruby-prof seemed great, but it needs a patched ruby interpreter to collect memory information.

After a bit of searching and trying, the simplest thing I managed to do was to

  • download the ruby sources
  • patch them
  • create a ruby-build package definition with them
  • install with rbenv

Here is a script that does this for ruby 1.9.2-p125 and gcdata patch.