Filtering by reference
Published 14 May 2018
This page describes the filters that allow you to filter by the references to objects.
For a summary of how to use them, see Using filters to find objects. For a description of which filters are most useful, see Suggestions for using filters.
Kept in memory exclusively by
Disposed objects
The disposed object itself is included in the objects shown. Objects which are disposed but are on the finalizer queue are not shown.
This filter is not available when you are profiling a .NET 1.1 application.
Event handlers
The event handler is included in the objects shown. Objects which are held in memory only by event handlers but are on the finalizer queue are not shown.
GC root of type GC root type
The GC root object is included in the objects shown.
Undisposed objects
Add class / interface...
Instances of the specified class are included in the objects shown.
Add namespace...
Objects which match your criteria but are on the finalizer queue are not shown.
When you select multiple criteria for this filter, objects are only shown if they are satisfy all of the selected criteria.
Referenced by
The Referenced by filters behave identically to the Kept in memory exclusively by filters, except that objects are shown if at least one of the paths of reference to the GC route goes through the specified type or GC Root. The reference may be direct or indirect.
(With the Kept in memory exclusively by filters, objects are shown if all of the paths of reference to the GC route go through the specified type or GC Root.)
When you select multiple criteria for this filter, objects are only shown if they are satisfy all of the selected criteria.
Never referenced by
The Never referenced by filters have the opposite behavior to the Objects referenced by filters. Objects are shown if none of the paths of reference (including indirect references) to the GC root goes through the specified type of GC Root.
When viewing the Class List, the number of classes shown when the Never referenced by filter is enabled, plus the number of classes shown when the Referenced by filter is enabled, might add up to more than the total number of classes in the application. This is because some classes might have instances that are referenced by the selected type, while other instances of the same class are never referenced by the selected type.
The Add class/interface filter can be especially useful. Some examples of when you might want to use this filter:
- You know that all the data in your application should be referenced by a single main class. Apply the Never referenced by an instance of class/interface filter to remove objects referenced by the main class from the results.
- Your application performs caching (for example, web applications that cache the query results). Cached objects are deliberately kept in memory for a period of time. Apply the Never referenced by an instance of class/interface filter to exclude objects referenced by a cache class (for example, System.Web.Caching.Cache, for ASP.NET applications).
Relationships between objects
Filters on the Filter by Reference tab enable you to narrow down your search for memory problems by concentrating on certain types of relationships between objects.
Referenced by
Objects may be in memory because another object references them; the object is on at least one of the chains of references between the selected object and a GC root.
Example: objects referenced by Object 1
In this example all objects except Object 2 are referenced by Object 1, either directly or indirectly. Note that the filter selection includes the specified object, Object 1.
Kept in memory exclusively by
Some filters show objects where the selected object is in all chains of references between the objects and a GC root - that is, objects are kept in memory only by the selected object.
Example: objects kept in memory by Object 1 (note that the filter includes the selected object, Object 1)
In this example, only four objects are kept in memory only by Object 1. Object 1 is not in all the chains of references between the remaining objects and their GC roots; for example, Object 4 has another GC root which references it via Object 2. Note that the filter selection includes the specified object, Object 1.