Skip to content

dmeremyanin/rack-leakin

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

About

Rack middleware that detects and handles memory leaks

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages