Skip to content

Instantly share code, notes, and snippets.

@tkling
Last active June 30, 2016 17:14
Show Gist options
  • Save tkling/9bd5c0d615d6da89710dbd25f3d949c1 to your computer and use it in GitHub Desktop.
Save tkling/9bd5c0d615d6da89710dbd25f3d949c1 to your computer and use it in GitHub Desktop.
Memory leak plan
memory plan:
============
- SSH to server
- add rbtrace (require: false) to gemfile, bundle install
- change passenger to only run 1 instance (via json config file)
- add this to before filter in applicaton_controller.rb:
require 'rbtrace'
- add this to application.rb:
require 'objspace'
ObjectSpace.trace_object_allocations_start
- start passenger (normal way - from deploy/scripts/application_start.sh)
- let server take some traffic
- take memory dump!
bundle exec rbtrace -p $PASSENGER_PID -e 'Thread.new{GC.start;require "objspace";io=File.open("./tmp/ruby-heap-#{DateTime.now.asctime}.dump", "w"); ObjectSpace.dump_all(output: io); io.close}'
- wait a bit and do the same thing a couple times
- comment out changes in application.rb, restart passenger again so that it's no longer in slow-mo (#trace_allocations_start slows things down)
- run dumps through analyzers like sam saffron's https://samsaffron.com/archive/2015/03/31/debugging-memory-leaks-in-ruby
- ???? hopefully that gives enough of a breadcrumb trail to figure out next steps
@ausmith
Copy link

ausmith commented Jun 30, 2016

๐Ÿ‘ ๐Ÿ‘ ๐Ÿ‘ ๐Ÿ‘ ๐Ÿ‘

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment