Fully featured low overhead profiler for Java EE and Java SE platforms.
Ultimate profiling and monitoring solution for Gradle, Maven, Ant, JUnit and TestNG.
Easy to use performance and memory profiler for .NET framework.

How do I avoid noise in memory profiling ?

Moderators: Vladimir Kondratyev, Anton Katilin

How do I avoid noise in memory profiling ?

Postby expert » Thu Jul 21, 2016 7:36 pm

Hey guys!

First I want to thank you for creating fantastic product. It helped me a lot with optimizing performance bottlenecks. Where I still struggle is memory profiling. I can't understand why I never get clean snapshot. Here is sample app I'm testing it with

https://github.com/cppexpert/akka_streams_hub

It's multithreading app that succeeds and should not have any memory leaks on exit. I run it with following YourKit options "onexit=memory,alloceach=1,allocsizelimit=1"

In on-exit snapshot I see tons of leaked objects. Only 40% of them reachable. "Hot spots by object size" says biggest offenders are byte[] and char[] from class loader.

So questions are

1) Why does it happen and how can I get snapshot that only clearly shows what wasn't freed ?
2) In this example I have an app that exists. It's not my real-life scenario. I have projection server that crashes with OutOfMemory exception. How can I catch what exactly leaking ? In OOM dump I have tons of stuff all over the code and none of "hotspots" look like cause of problem.

I'm using JDK 1.8, IDEA 2016.2 and YourKit 2016.06-b15

Thank you!
expert
 
Posts: 2
Joined: Thu Jul 21, 2016 7:24 pm

Re: How do I avoid noise in memory profiling ?

Postby expert » Thu Jul 21, 2016 7:41 pm

I forgot to add zip of on exit snapshot.
https://dl.dropboxusercontent.com/u/708 ... apshot.zip

Also my order no is 515761563.
expert
 
Posts: 2
Joined: Thu Jul 21, 2016 7:24 pm

Re: How do I avoid noise in memory profiling ?

Postby Anton Katilin » Fri Jul 22, 2016 12:09 pm

Hello,

In on-exit snapshot I see tons of leaked objects. Only 40% of them reachable.

Sorry, your statement is inaccurate. Leaks are by definition reachable.
https://www.yourkit.com/docs/java/help/memory_leaks.jsp

Unreachable objects, in opposite, are those that are not reachable anymore but have not been collected yet by the garbage collector.
https://www.yourkit.com/docs/java/help/reachability.jsp

1) Why does it happen and how can I get snapshot that only clearly shows what wasn't freed ?

You see all unreachable objects existing in the heap at the moment of exit. If you application didn't exit, they would have been eventually collected at a later time point.

Simply inspect reachable objects and ignore unreachable.

2) In this example I have an app that exists. It's not my real-life scenario. I have projection server that crashes with OutOfMemory exception. How can I catch what exactly leaking ? In OOM dump I have tons of stuff all over the code and none of "hotspots" look like cause of problem.
You should open the memory snapshot captured on OutOfMemoryError (such snapshots are enabled by default when you run with the agent - see https://www.yourkit.com/docs/java/help/ ... memory.jsp ) and analyze what objects are strongly reachable.

https://www.yourkit.com/docs/java/help/ ... _usage.jsp
https://www.yourkit.com/docs/java/help/memory_leaks.jsp

Best regards,
Anton
Anton Katilin
 
Posts: 5575
Joined: Wed Aug 11, 2004 8:37 am

Re: How do I avoid noise in memory profiling ?

Postby Anton Katilin » Fri Jul 22, 2016 12:13 pm

Hint: to check whether your test leaks objects, please use the profiler's generations feature:
https://www.yourkit.com/docs/java/help/generations.jsp
Advance generation right before starting the test and after it finished. If you see strongly reachable objects in the generation between these events they are those your test leaked.
Anton Katilin
 
Posts: 5575
Joined: Wed Aug 11, 2004 8:37 am


Return to Java Profiler

Who is online

Users browsing this forum: Bing [Bot] and 12 guests