Browse the Ruby on Rails Community.

You are here: Browse Railsplugins Bleak House

Bleak House

BleakHouse

A library and Rails plugin for finding memory leaks.

License

Copyright 2007 Cloudburst, LLC. See the included LICENSE file. Portions copyright 2006 Eric Hodel and used with permission. See the included LICENSE_BSD file.

Features
  • leak-proof C instrumentation
  • logs object counts, real and virtual memory usage, and filled/free heap slots
  • easy Rails integration
  • automatic generation of nested object charts

    Requirements

  • A unix-like operating system.
  • Ruby 1.8.6

= Usage

Installation

First, install the plugin in your Rails app: ./script/plugin install svn://rubyforge.org/var/svn/fauna/bleak_house/trunk

You need to compile the BleakHouse patched Ruby build. In the plugin directory, run: rake ruby:build

This gives you a Ruby binary named ruby-bleak-house alongside your regular binary.

(BleakHouse is also available as a gem: sudo gem install bleak_house. If you use the gem, require 'bleak_house' in config/environment.rb. You will also have to manually install the bleak_house:analyze Rake task.)

Profiling a Rails app

To profile your application (ideally, in production mode, on an actual application server): RAILS_ENV=production BLEAK_HOUSE=true ruby-bleak-house ./script/server

Browse around manually, thrash your entire app with a script, target troublesome controllers/actions, etc.

Then, to analyze: RAILS_ENV=production rake bleak_house:analyze

And then look in log/bleak_house/.

= Extras

Options

You also can set the SMOOTHNESS environment variable if you want. The SMOOTHNESS setting just averages frames together. This is not a rolling average: 10 frames become 5 at SMOOTHNESS=2.

Using BleakHouse outside of Rails

If you want finer snapshots than every action, or want to use the plugin outside of Rails, see the BleakHouse::CLogger class.

Troubleshooting

If you see the error Symbol not found: _rb_gc_heaps_used, it means you installed the patched binary, but tried to profile the server with the regular binary.

You may get library require errors if you install ruby-bleak-house 1.8.6 alongside a different verson of Ruby. You could try to patch your local version of Ruby instead, or you could just upgrade to 1.8.6, which has a good trackrecord of stability.

Reporting problems
  • http://rubyforge.org/forum/forum.php?forum_id=13983
Further resources
  • http://blog.evanweaver.com/articles/2007/05/12/let-me-hit-you-with-some-knowledge
  • http://blog.evanweaver.com/articles/2007/05/06/leak-proof-direct-heap-instrumentation-for-bleak_house
  • http://blog.evanweaver.com/articles/2007/04/28/bleak_house

NOTE: This description has been extracted from the Plugin README and so the formatting may need updating to make browser friendly