Rack middleware that detect and handle memory leaks
Ruby
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.
lib
.gitignore
Gemfile
LICENSE.txt
README.md
Rakefile
rack-memory.gemspec

README.md

Rack::Leakin

Rack middleware that detect and handle memory leaks

Usage

Add this line to your application's Gemfile:

gem 'rack-leakin'

Then, if you are using Rails, simply add to initializer:

Rails.application.config.middleware.use Rack::Leakin

You can set threshold in kilobytes and the handler:

Rack::Leakin.threshold = 131072 # default, 128MB

For example, it may be useful to send exceptions to Airbrake:

Rack::Leakin.handler = lambda do |env, beginning, ending|
  Airbrake.notify \
    :error_message => "Memory leak detected, from #{beginning}KB to #{ending}KB",
    :error_class   => 'MemoryLeak',
    :parameters => {
      :request_uri => env['REQUEST_URI'],
      :method => env['REQUEST_METHOD']
    }
end