Can I use ruby-prof to track down a memory leak?

254 views
Skip to first unread message

John Gallagher

unread,
Jan 6, 2014, 1:29:37 PM1/6/14
to ruby-opt...@googlegroups.com
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?


Setup

Gems

rails 3.2.16

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

The documentation says:

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.

That means I can't use it for memory leak tracking... is that right?

Roger Pack

unread,
Jan 6, 2014, 2:44:17 PM1/6/14
to ruby optimization
So you basically want something like
20.times {
  run_my_program
}
ObjectSpace.each_object{|o| p o.where_allocated }

?

I've seen some patches from tmm1 in the regard, this one and another somewhere else?
https://www.ruby-forum.com/topic/4412059



--
 
---
You received this message because you are subscribed to the Google Groups "ruby optimization" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ruby-optimizat...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Reply all
Reply to author
Forward
0 new messages