Is there any difference between Java Memory Analysis Tools (profilers like Yourkit Java Profiler) and Java Memory Leak Detection Tools? (From my searches, the difference is pretty hard to notice in what tools are concerned, but it sounds to me like a difference in the approach manner). If there is, are there any free (available for download) tools for memory leak detection (not memory profiling)? Thank you in advance!
2 Answers
Think of Memory Leak Detection Tools as just an optimized version of a memory analysis tool that helps you find a problem without having to go scouring through the data yourself.
I've used Yourkit. I would argue it has both features. While it doesn't explicitly point out "yo dude, your leak is on this line of code" it provides utility for comparing snapshots of memory to show what changed over time and provides various utilities for chasing the references of objects to figure out why they are still being held in memory.
Depending on your definition of leak detection tools, one could argue that the graph in JConsole that shows heap memory usage is a leak detection tool. Look at a graph of heap consumption over a long enough period of usage...if the average value keeps going up, good chance you have a leak.
I'm not related to the Yourkit folks, but I can recommend the tool. It could be better, but it isn't bad. I use it for both memory and cpu performance analysis. I do regular load and memory testing (JConsole/JMX and other methods) on our product and use Yourkit when something seems odd. About once every 2-4 months I do a cpu analysis looking for easy to fix performance bottlenecks (our load testing catches major problems).
Strictly speaking, there are no memory leaks in java in the C/C++ sense: memory allocation with no more reference to it.
So when the term "leak" is used in the java context, sometimes it just means a big memory structure. Some tools call them "leak suspects", because they cannot judge if a memory structure is big due to the nature of the problem or by mistake.
And sometimes "leak" is used in the dynamic sense: a memory structure that is growing over time.
So in the first place, you need a memory tool that gives you a quantitive overview on memory distribution and referer structure in a java heap dump snapshot. Having that, you can investigate the dynamic behaviour by comparing two or more snapshots.
If these tools offer an addional "Leak-Feature" (JProbe's Memory-Leak-Doctor, Eclipse-MATs Memory-Leak Report) it indicates that they have problems presenting a really comprehensive view on memory structures in the first place.
If you are looking for a free download, look at the
and at