Work with Object Sets
Object set is a number of objects selected by specific condition. To ease the understanding, think of an object set as of the result of some query, like "Select all objects of the string type promoted to Gen 2", or "Select all objects retained in memory by the instance A", and so on. An ObjectSet
instance is returned as a result of the ObjectSet.GetObjects
and ObjectSet.GetExclusivelyRetainedObjects
methods.
To slice data by a number of conditions, you can build chains of GetObjects
calls. The ObjectSet
type has two properties that you can use in test assertions: ObjectsCount
and SizeInBytes
.
Example
For example, the following code asserts that there are no string
and Foo
objects in the Large Object Heap:
dotMemory Unit also provides alternative syntax for object set queries. You can use the ==
, &
, and |
logic operators to combine a number of queries. For example:
ObjectSet class
Represents a set of objects in memory.
ObjectSet methods
Name | Description |
---|---|
| Gets a subset of objects by a specific condition. The condition is defined by a Returns an instance of the |
| Gets a subset of objects by a specific condition. The condition is defined by a reusable query - an instance of the ObjectSetQuery type. For more information, refer to QueryBuilder. Returns an instance of the |
| Gets a set of objects that are exclusively retained (dominated) by the current object set. Returns an instance of the |
| Returns a collection of objects of the TypeMemoryInfo type. Each object represents a particular type from the source object set and carries info about the number of objects of that type and their total size. |
ObjectSet properties
Name | Type | Description |
---|---|---|
|
| Total number of objects in the set. |
|
| Total size of objects in the set in bytes. |
ObjectProperty class
Selects objects in a set by a specific condition: type, interface, and others.
ObjectProperty methods
Name | Description |
---|---|
| Creates the "Select all objects that cause the event handlers leak" query. Learn more. Returns |
| Creates the query "Select all objects that are not exclusively retained in memory (in other words, objects that are retained by more than one object)". Returns |
ObjectProperty properties
Name | Type | Description |
---|---|---|
|
| Allows selecting objects by type. |
|
| Allows selecting objects by interface. |
|
| Allows selecting objects by namespace. |
|
| Allows selecting objects by assembly. |
|
| Allows selecting objects by generation. |
TypeProperty class
TypeProperty
is used to create "select objects by type" queries.
TypeProperty Methods
Name | Description |
---|---|
| Creates the "Select all objects of particular types" query. The list of types is passed in a Returns |
| Creates the "Select all objects of a particular type" query. Open generic types are also supported. Returns |
| Creates the "Select all objects that do not belong to particular types" query. The list of types is passed in a Returns |
| Creates the "Select all objects that do not belong to a particular type" query. Open generic types are also supported. Returns |
| Creates the "Select all objects of particular types" query. The list of types is passed in a Returns |
| Creates the "Select all objects that do not belong to particular types" query. The list of types is passed in a Returns |
InterfaceProperty class
InterfaceProperty
is used to create "select objects by interface" queries.
InterfaceProperty Methods
Name | Description |
---|---|
| Creates the "Select all objects that implement particular interfaces" query. The list of interfaces is passed in a Returns |
| Creates the "Select all objects that implement a particular interface" query. Open generic interfaces are also supported. Returns |
| Creates the "Select all objects that do not implement particular interfaces" query. The list of interfaces is passed in a Returns |
| Creates the "Select all objects that do not implement a particular interface" query. Open generic interfaces are also supported. Returns |
| Creates the "Select all objects that implement particular interfaces" query. The list of interfaces is passed in a Returns |
| Creates the "Select all objects that implement particular interfaces" query. The list of interfaces is passed in a Returns |
NamespaceProperty class
NamespaceProperty
is used to create "select objects by namespace" queries.
NamespaceProperty methods
Name | Description |
---|---|
| Creates the "Select all objects that belong to particular namespaces" query. The list of namespaces is passed in a Returns |
| Creates the "Select all objects that do not belong to particular namespaces" query. The list of namespaces is passed in a Returns |
AssemblyProperty class
AssemblyProperty
is used to create "select objects by assembly" queries.
AssemblyProperty methods
Name | Description |
---|---|
| Creates the "Select all objects that belong to particular assemblies" query. The list of assemblies is passed in a Returns |
| Creates the "Select all objects that do not belong to particular assemblies" query. The list of assemblies is passed in a Returns |
| Creates the "Select all objects that belong to particular assemblies" query. The list of assemblies is passed in a Returns |
| Creates the "Select all objects that do not belong to particular assemblies" query. The list of assemblies is passed in a Returns |
GenerationProperty class
GenerationProperty
is used to create "select objects by generation" queries.
GenerationProperty methods
Name | Description |
---|---|
| Creates the "Select all objects from particular managed heap segments" query. The list of heap segments is passed in a Returns |
| Creates the "Select all objects that do not belong to particular managed heap segments" query. The list of heap segments is passed in a Returns |
Generation enum
Represents certain managed heap segments:
Value | Description |
---|---|
| Generation 1 heap segment. |
| Generation 2 heap segment. |
| Large object heap. |
TypeMemoryInfo class
TypeMemoryInfo
carries info about a group of objects of the same type: a number of objects, and their size. Instances of the TypeMemoryInfo
class are a result of objects grouping via the GroupByType()
method.
TypeMemoryInfo properties
Name | Type | Description |
---|---|---|
|
| Total number of objects of the |
|
| Total size of objects of the |
|
| Fully qualified name of the |
|
| Type of objects represented by this instance of the Can be |