InfoQ

News

Find Memory Leaks in Your Rails Application with BleakHouse

Posted by Sebastien Auvray on May 10, 2007

Community
Ruby
Topics
Ruby on Rails
Tags
Rails ,
Memory Leaks

While the agility of Rails has never been in doubt, there is often controversy about its performance.

DTrace is a nice dynamic framework to analyze the behavior of your application as the Twitter team proved recently. A new tool in the battle for memory issues is the Rails plugin BleakHouse by Evan Weaver. One of the advantages of a dynamic language like Ruby is its ability to introspect: examining the state of your application from within the application itself. But one has to be careful when using ObjectSpace (the Ruby garbage collected object heap explorer). Indeed, BleakHouse in a first version took advantage of ObjectSpace to take snapshots of Rails application, but Evan Weaver found out ObjectSpace is not quantum: using it changes its own state.

BleakHouse now comes with a leak-free C implementation that directly instruments the heap. The advantage is that it now charts actual memory usage (swap, real, and combined) and it’s faster than before.

It produces charts of references by controller, by action, and by object class.

Bleakhouse needs gruff (and therefore rmagick). Since it is a C implementation, BleakHouse also needs a patched Ruby binary to monitor your application. Once the plugin installed and your environment set as production, your application will be tracked. At the end, you will run a rake goal to generate the graphs:

Bleakhouse reminds InfoQ of the fifth suggestion from Charles Nutter about making Ruby better: getting rid of ObjectSpace, all the more when at the end one has to patch its vm to do some monitoring.

ObjectSpace harms Ruby by limiting the flexibility of its garbage collecting and threading subsystems, and should be eliminated.

Java has a lot of efficient heap analyser, you could wonder where are all the RProbe, RProfiler for Ruby? I guess with time, new VMs, more companies involved, such tools should arrive...

Been looking for a tool like this by Jan Fredrik Øveraasen Posted May 13, 2007 3:40 PM
Tools for Ruby by Stephen Kellett Posted Oct 26, 2007 6:22 AM
  1. Back to top

    Been looking for a tool like this

    May 13, 2007 3:40 PM by Jan Fredrik Øveraasen

    can`t wait for using this for my work in progress ruby application:)

  2. Back to top

    Tools for Ruby

    Oct 26, 2007 6:22 AM by Stephen Kellett

    The article has the question "Where are all the RProbe, RProfiler for Ruby?".

    There have been coverage, memory, profiler and flow tracer tools for Ruby for several years now. Software Verification provide them. They have the same user interface as their tools for other languages, so if you know the C++ or JavaScript version of one of the tools you automatically know how to use the Ruby version.

    Stefan Kaes wrote about Ruby Performance Validator in his InfoQ article on Ruby Performance. The other tools are Ruby Memory Validator, Ruby Coverage Validator and two in beta for flow tracing and thread analysis.

Educational Content

Brian Marick on 4 Challenges and 5 Guiding Values of Agile Software Development

Brian Marick takes us through a quick tour of the most important values and challenges to adopting Agile successfully (they aren't the typical challenges and values we hear in the community).

Are You a Software Architect?

The line between development and architecture is tricky. Does it exist at all? Is an ivory tower actually needed? There's a balance in the middle, but how do you move from developer to architect?

Agile – A Way of Life and Pragmatic Use of Authority

The word 'authority' sometimes produces an allergic response in hard-line agilists. Freedom and authority – both are bad if misused and both are good if used in right spirit for a noble cause.

Getting Started with Grails, Second Edition

"Getting Started with Grails" brings you up to speed on this modern web framework. Companies as varied as LinkedIn, Wired, and Taco Bell are all using Grails. Are you ready to get started as well?

Using ITIL V3 as a Foundation for SOA Governance

Those familiar with only ITIL V2 often scoff at the thought that ITIL could serve as a governance framework for SOA. With ITIL V3, the focus of the framework shifted towards service-orientation.

Adrian Colyer on AspectJ, tc Server and dm Server

SpringSource CTO Adrian Colyer discusses AspectJ, SpringSource's dm Server and tc Server products, OSGi and Scrum.

Adam Wiggins on Heroku

Heroku's Adam Wiggins talks about Rails, Background Jobs, Add-Ons, Ruby, and how Heroku manages to work around Ruby's inefficiencies using Erlang and other languages.

SOA as an Architectural Pattern: Best Practices in Software Architecture

For Grady Booch the foundation of a good architecture is patterns, SOA being just one of many patterns. In this Second Life presentation, Booch attempts to bring more clarity on what architecture is.