Using the Difference Column in the Memory Views



1. Introduction

In contrast to allocation call stack recording, where you can restrict the displayed objects to a certain period of time, a common situation is that you want to retain all recorded objects but still see the difference of object allocations with respect to a certain point in time. In particular, you might be interested in which classes have a decreasing allocation count, something that would not be possible with allocation call stack recording.

2. Memory views with differencing

By default the difference column is not displayed. Only when you choose View->Mark Current Values or the corresponding toolbar button, the difference column is shown as the next-to-last column. The following views in JProfiler have an optional difference column:

In most cases you'll be interested in sorting the view by the values in the difference column. There are two sort modes that can be adjusted in the view settings dialog. By default, sorting is done for object counts ("sort by values"), but you can switch to "sort by percentages", if you want to focus on relative changes.

In addition, you can choose to sort by absolute values. With absolute ordering, the absolute value of the difference will be used for sorting. This is appropriate if you're interested in the biggest changes. With normal ordering, you'll have positive differences at the top, then a usually long list of zero differences and finally the negative differences. This is the right setting if you're looking for a memory leak and are only interested in positive differences.

3. Differencing and the heap walker

The difference column only shows a calculation, there's no fixed set of objects behind this number. Because of that, it is not possible to select the "difference objects" and work with them in the heap walker. To select objects based on their time of creation, please see the article on allocation call stack recording.

4. The class tracker

The class tracker view provides a way to capture the history of instance counts over time for selected classes or packages in the form of a graph. However, you have to select the tracked classes or packages in advance, so the class tracker is best used on classes or packages that appear suspicious from the differencing in the all objects or recorded objects view.