Grocery
Grocery

Reputation: 2274

Searching for a memory leak on Jruby/Rails/Tomcat application with YourKit

I had a misfortune of getting a task of searching for an unconfirmed memory leak. This is my first time using YourKit so while I know what I should be looking for, I have no idea where to look and how.

My understanding is that over time memory consumption goes up because certain objects are not being released. Pretty hard to do that in Rails, but I guess somebody figured out how.

Here's how memory telemetry looks like:

what a trend!

Ignoring the fact periods between GC increase over time, it looks like Old Gen memory is going up... maybe.

Now we probably need to know what objects are getting piled on there and what spawns them.

Steps I've taken so far:

  1. triggered CG
  2. started 'Object Allocation Recording' (each 100th... I have a feeling it might be useful for something)
  3. Waited for while
  4. Triggered another CG
  5. Did a memory dump

After opening the memory snapshot in YourKit I have no idea what I should be looking for.

that's bad, right?

There's Call Tree in Allocations. Expanding the tree gives me a hint of some of the Rails code being run, but I have no idea if what I'm looking at is actually what I need.

wtf am i looking at

Any Java profiling, Yourkit wielding, persons able to point me in a right direction?

Edit: Example of what I can see in Merged paths view:

enter image description here

Upvotes: 1

Views: 651

Answers (1)

Vladimir Kondratyev
Vladimir Kondratyev

Reputation: 725

1) Do not use object allocation recording. It is almost useless for memory leak finding.

2) I recommend to periodically advance objects generation (it is very fast and does not add overhead). Take a look at http://www.yourkit.com/docs/java/help/generations.jsp

You will be able to split objects by "age" and understand why heap grows.

Since you are using Tomcat it might be helpful to take a look at "Web applications" http://www.yourkit.com/docs/java/help/web_applications.jsp If your application has problem with class reloading/redeploying it will be visible there.

Best regards, Vladimir Kondratyev YourKit, LLC

Upvotes: 3

Related Questions