Home How do I track down a memory leak in my Ruby code?
Reply: 0

How do I track down a memory leak in my Ruby code?

user1375
1#
user1375 Published in June 20, 2018, 10:52 pm

Question

I'm debugging a memory leak in a rake task. I want to see a call stack of:

  • Living objects
  • What object or line originally allocated those objects

Is this possible with ruby-prof?

If not, what tool should I use?

Setup

Gems

  • rails 3.2.16
  • event_bus 1.0.0 (https://github.com/kevinrutherford/event_bus)
  • activerecord-fast-import (https://github.com/jsuchal/activerecord-fast-import)

Rake task

  • Imports a CSV file directly into a MySql database using DATA LOAD INFILE and Active Record objects.

What I've Tried

I've tried the modes

  • RubyProf::ALLOCATIONS
  • RubyProf::MEMORY

All it says in the documentation is:

RubyProf::ALLOCATIONS Object allocation reports show how many objects each method in a program allocates.

RubyProf::MEMORY Memory usage reports show how much memory each method in a program uses.

This implies that ruby-prof just reports on the total allocation of objects, not just the ones that are living.

I've tried Ruby-Mass and Bloat Check but neither seem to be able to do what I want. Ruby-Mass also crashes because it's finding FactoryGirl objects in memory for some reason...

You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.406344 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO