Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Memory leaks in Ruby applications

Lightning talk about some solutions to finding, preventing memory leaks, churn and bloat.
http://camillebaldock.co.uk/memory-leaks-ruby-applications/

Website: http://camillebaldock.co.uk
Twitter: @camille_

  • Login to see the comments

Memory leaks in Ruby applications

  1. 1. Visual representations of memory issues in Ruby and Rails Camille Baldock, @camille_
  2. 2. Bloat • Memory usage has grown with data set • Loading too many objects at once
  3. 3. Memory leaks • Objects that will never be released by the garbage collector • Objects whose size grows the longer the process runs
  4. 4. Memory churn • Allocating and deallocating a LOT of objects
  5. 5. • Oink • Ruby object graphs • A few best practices… !
  6. 6. Configuring Oink • Rails.application.middleware.use( Oink::Middlew are, :instruments => :memory ) ! • Rails.application.middleware.use( Oink::Middlew are, :instruments => :activerecord )
  7. 7. ! • ReportsController#show • Max heap size: 157524 KB • Number of AR objects: 14565
  8. 8. Be proactive about being lazy
  9. 9. Where are the leaks ? • Look at the object graph in memory ! • ObjectSpace.find_references • A new ObjectGraph standard library
  10. 10. Journey through the object graph
  11. 11. Counting objects…
  12. 12. Finding something horrible…
  13. 13. ! • status?timestamp=110143244 • status?timestamp=110143245 • ….
  14. 14. Stop using global state ! • Global variables • Class variables • Per-process instance state • …
  15. 15. My app is still slow…
  16. 16. Sources of memory churn
  17. 17. Mutation limits allocation
  18. 18. • Twitter: @camille_ • Github: camilleldn ! • Conrad Irwin, Object Graph exploration for Ruby memory leaks • Oink gem, https://github.com/noahd1/oink • Boston Ruby - Joe Ferris - Memory Issues in Rails

×