I'm currently trying to figure out where a big memory leak is hiding. I
press a button and 1 out of 3 times my memory increases by 20MB, even
though is should not increase at all.
It would be a great help in this situation to be able to take a hprof file
before and one after, and get a list of classes that were added. A diff so
to speak. Then at least I could see what causes the 20MB and give me a
good starting point. Now it's educated guessing and poking.
well we already offer such a diff, although we want to improve this
When you open the histogram view of a heapdump, try the rightmost icon in
the icon bar (compare to another heapdump). You can compare two heapdumps,
which should be already be opened. Since the compare functionality works
on the histogram (aggregating objects on class level), it should be almost
what you desire.
Let me explain: The heap dump identifies objects by its object address.
But this object address is not stable. Whenever the Garbage Collector
moves an object (within the eden spaces, into the old generation, etc.),
the object is assigned a new object address. Therefore it is not possible
to say whether an object was just moved or whether one instance was
garbage collected and another one created.
Hence, the Memory Analyzer compares heap dumps on an aggregate level. This
is the histogram (objects group by classes) or the class loader histogram
(objects grouped by the name of the class loader).
BTW, profiling tools overcome this limitation by assigning unique object
ids during the profiling run. This, of course, is an overhead which might
be perfectly acceptable for debugging, but is usually not done in
To compare two snapshots open a baseline snapshot and a later snapshot and from the snapshot Class Histogram view press the
Compare to another Heap Dump
toolbar button, and select the baseline snapshot to see the differences. There is also a more general comparison view using the compare basket. Tables and trees are added to the compare basket from the Navigation History.
There isn't time at the moment to update the tutorials further.