Heap Utilization Tracker

The heap utilization tracker can be used to analyze and optimize the way the garbage collected heap is used. Tracking heap utilization is an advanced feature that is disabled by default. In order to analyze the information provided by the heap utilization tracker, you should have a good knowledge of how the generational garbage collector of the .NET runtime works.

The heap utilization tracker keeps track of the generation of each allocated instance and whether the instance was allocated in the large object heap. It then records in which heap (generation #0, #1, #2 or large) the instance was garbage collected or in which heap it resides at the time of the snapshot if it still has not been garbage collected.

Usually, when a heap snapshot is collected, a full garbage collection is performed, and thus all surviving instances will reside in the generation #2 heap, but, when heap utilization tracking is enabled, it is also possible to collect a heap snapshot using only a generation #0 garbage collect. This will lower the profilers’ influence on the generations of the heap and will also allow unreachable instances to be counted.

You should only use the generation #0 heap snapshot when doing heap utilization analysis. The normal snapshot is more thorough in making sure that all unreachable instances have been garbage collected.

NOTE! To get more accurate numbers of the heap utilization, you should try to make sure that several garbage collections of all generations have been performed between two consecutive snapshots.

Example:

Assume that 1000 instances have been allocated since the comparison snapshot and that the selected snapshot was collected using a generation #0 garbage collection 100 seconds later.

      900 instances were garbage collected before the selected snapshot

700 were garbage collected by the first generation #0 GC

100 were garbage collected by the first generation #1 GC

100 were garbage collected by a generation #2 GC

      25 instances are live in generation #1 at the time of the selected snapshot

      75 instance are live in generation #2 at the time of the selected snapshot

If we sum this up, the distribution of the 1000 instance allocations is as follows:

Generation #0: 700 instances

Generation #1: 100 + 25 = 125 instances

Generation #2: 100 + 75 = 175 instances

If Show heap utilization as percent is selected, then the heap distribution numbers are presented relative to the total number of allocations:

Allocs (or Allocs/sec):     1000 (or 10/sec)
Allocs in gen #0:           70%
Allocs in gen #1:           12.5%
Allocs in gen #2:           17.5%

If Show heap utilization as percent is not selected, the heap distribution numbers will be presented in the same way as the total number of allocations (i.e., it depends on the /sec setting).

.NET Memory Profiler User Manual

© Copyright 2002-2019. SciTech Software AB.

For information about .NET Memory Profiler, see the product site at http://memprofiler.com

.NET Memory Profiler is developed by SciTech Software AB