.NET Memory Profiler Instance Graph

The instance graph gives you a visual overview of how a managed instance is being used, how it is related to other instances, and, maybe most importantly, how roots are preventing it from being garbage collected.

Instance graph demo
Click on image to play demo.

The instance graph is available in the Type/Filter details view and the Instance details view.
The graph can include all instances that are related to the selected instance. This includes instances and roots that can reach the selected instance, and instances that are reachable from the selected instance. By default, only root path instances and held instances are included in the graph, i.e. the instances and roots that are preventing the selected instance from being garbage collected and the instances that are uniquely reachable from the selected instance. To select which instances to include in the graph, use the Include menu ( Include instances menu).

Combined instances graph

The graph under the Type/Filter details view shows the root paths of the selected instances, the instances with a specific shortest root path, or the instances that share a common allocation call stack.

Type and Filter details instances graph demo
Click on image to play demo.

Select roots to include/exclude in the instance graphs

It is possible to select which roots to include in the instance graph. This is especially useful when investigating an "inspection-only" snapshot, i.e. when the profiler has not induced a garbage collection or performed other heap clean-up actions before the snapshot.

The screencast below shows how roots can be excluded to simplify the instance graph of a suspected memory leak instance (this is based on an actual memory leak detected in a memory dump of .NET Memory Profiler).

Only include static fields to simplify instance graph
Click on image to play demo.

If excluding roots causes all roots to be removed, then the instance graph will consist of only the selected instance.

Excluding finalizers from an instance with only finalizer roots
Click on image to play demo.

Investigating root paths in a large graph

If the instance graph is large, it can be hard to locate specific root paths. In this case the Align root path command is useful. This command is available from the popup window of each instance, root, and reference in the graph, as well as from the right click menu. When selected, it will find the shortest root path that passes through the instance, root, or reference, highlight the root path and group all instances. Root paths can also be selected using the navigation buttons that are provided on the sides of the graph. For more information watch the root path navigation demo.

Large instance graph reduction

An instance graph can easily become much larger than can be conveniently presented visually. To avoid presenting too large graphs, .NET Memory Profiler will reduce the graph by combining groups of instances and roots into single graph nodes. The profiler tries to select groups so that the overall structure of the graph is affected as little as possible.

Combined instances can be expanded by using the Expand command that is available in the popup window and right-click menu of the combined instances and combined references. The expand options depend on how the instances and references have been combined. Typically they include options for expanding a specific type, a field, or just a number of instances. For more information see the demo.

Download .NET Memory Profiler to see how it can help you find memory leaks and optimize memory usage in your application.

Download Free Trial

© Copyright 2001-2023. SciTech Software AB
All rights reserved.

CONTACT INFO

SciTech Software AB
Ynglingavägen 1-3
SE-177 57 Järfälla
Sweden

E-mail: mail@scitech.se
Telephone: +46-706868081