Introduction
Before looking into the capabilities that Memory Analyzer offers in the area of comparison let us make some explanation. Object IDs which are provided in the heap dump formats supported by MAT are just the addresses at which the objects are located. As objects are often moved and reordered by the JVM during a GC these addressed change. Therefore they cannot be used to compare the objects. This basically means that if one compares two different heap dumps (although from the same process) it is not possible to point to the concrete objects different between the two heap dumps. However, one can still perform comparison on the aggregated results (e.g. the class histogram) and analyze how the amount of object and the memory they take has changed.
Memory Analyzer offers the possibility to compare not only the global class histograms of two different heap dumps, but an arbitrary number of table-formatted results - for example the retained sets of three different objects. It doesn't matter if the tables which are compared come from one and the same or different heap dumps.
Here is a quick description how to compare several retained set tables.
All queries which are executed in Memory Analyzer can be seen in the Navigation History View. From this view one can add the results to be compared to the Compare Basket. The Navigation History is still per heap dump, therefore if one wants to compare tables from different heap dumps then they have to be added one by one. Multiple tables from one heap dump can be added at a time.
Using the tool bar of the Compare Basket one can modify the order in which tables should be compared, i.e. select which result should be the baseline, which comes second, etc...
... and see the result.
By default the absolute values of all tables will be shown for every compared property, e.g. number of objects, shallow size, etc... One can now change between deltas and absolute values, as well as select which columns should be compared:
If the tables have been compared using
then it is possible to perform different set operations on the comparison result.