So your Rails app is taking up a lot of RAM. What else is new? But perhaps this isn't just the way things are. Perhaps your application's memory footprint is being enlarged by one or more bloated gems.

I recently stumbled across a very cool project by Richard Schneeman. It's called derailed, and is a collection of automatic benchmarking tools. Here's the github repo.

All you need to do is add it to your gemfile like so:

gem 'derailed', group: :development
gem "stackprof", group: :development

Then you can see exactly how much memory each of your gems requires at compile time:

Use the bundle:mem command to see how much ram each of your gems uses at compile time Use the bundle:mem command to see how much ram each of your gems uses at compile time

You can also see how many objects are allocated by your gems at load time.

Use the bundle:objects to see information about object allocation at load time Use the bundle:objects to see information about object allocation at load time

There are even tools for measuring memory usage as your application runs. I haven't had a chance to check these out personally yet, since you have to be able to run your app in production mode on your development computer.

Get the Honeybadger newsletter

Each month we share news, best practices, and stories from the DevOps & monitoring community—exclusively for developers like you.
    author photo
    Starr Horne

    Starr Horne is a Rubyist and former Chief JavaScripter at Honeybadger. When she's not fixing bugs, she enjoys making furniture with traditional hand-tools, reading history and brewing beer in her garage in Seattle.

    More articles by Starr Horne
    An advertisement for Honeybadger that reads 'Move fast and fix things.'

    "We love Honeybadger. Not only is it a fab tool and very affordable, they feel like a partner - whenever we needed help we got FIRST CLASS service."

    Fix errors, eliminate performance bottlenecks, and dig into the details faster than ever before. With support for Ruby, Elixir, and 8 other languages, Honeybadger is the best way to gain real-time insights into your application’s health and performance.

    Get started for free
    Simple 5-minute setup — No credit card required