How do I compare memory heap dumps in Netbeans?
What I have done is to configure my project to use profiling, then added several profiling points at chosen lines of code (similar to setting breakpoints). These profiling points trigger a "snapshot", which creates a memory dump.
As my application is running, the profiling tab lists each of the profiling points, and marks the number of hits it has encounteed, providing a link to open a report for that profiling point. In addition, the profiler control panel adds the new snapshots to a list.
If I open these reports and follow the links, or open the snapshots from the control panel, in both cases, Netbeans opens a snapshot tab with Summary, Classes, Instances and OQL subscreens.
If I select one of them from the Profiler control panel, and press save, the file gets saved in HPROF format.
If I select the menu Profile --> Compare Memory Snapshots, it only allows me to select NPS format files, of which I cannot obtain any.
I believe Compare Memory Snapshots sounds like it should be able to compare heap dumps, but I cannot figure out how to do it.
Questions
-
Where is Netbeans putting the NPS files (if it is indeed creating them)? If not how do I get Netbeans to create NPS files triggered from profiling points?
-
Is there a way to get Netbeans to compare HPROF files, since that is the memory heap dump after all?
-
Or am I simply completely overlooking something altogether?
Thanks!
Background
Using Netbeans 6.7.1.
I am doing memory profiling for a really large & complex application that has a memory leak problem. I have managed to solve large chunks of the leaks using a combination of Netbeans’ profiler & JHAT (command line util that comes with JDK). It’s the remaining stragglers that I need a more powerful heap analysis capabilities for – the
hypothesis-first approach that worked previously is becoming decreasingly effective.
This question’s really specific, for more background see a question I have asked previously.
Unfortunately, I was not asking for recommendations on other tools which can do this.
I have since found that Netbeans does indeed support comparison of memory heap dumps, but only indirectly. Edit the profiling points such that the "Snapshot" is selected over "heap". This means that Netbeans will produce a
.npsfile instead of a.hproffile.The
.npsfile is Netbean’s own proprietary file format, whereas.hprofis the "universal" heap dump format, understood by almost all profiling tools, including JHAT, MAT & Netbeans.However, the limitation with Netbeans is that it can look at
.hproffiles, and analyse them, but it cannot compare them to another.hproffile. It can, though, compare one.npsfile to another.npsfile. However the level of analysis available is limited with.npsfiles, so that’s the trade-off.So, to answer my own questions: