Work with Memory
To analyze memory, first you need to take a memory dump (in terms of dotMemory Unit, called memory checkpoint or snapshot). To take memory checkpoints, you should use the
Check method of the static dotMemory type. Therefore, the
dotMemory.Check is an essential starting point for almost any memory test.
MemoryCheckPoint instance returned by
dotMemory.Check can be used as a baseline for comparison with other checkpoints, or for checking memory traffic between checkpoints. See Compare Snapshots and Work with Traffic correspondingly.
A lambda passed to the
dotMemory.Check method allows slicing and dicing memory by specific conditions. An instance of the Memory type passed to that lambda contains all memory data at the current execution point. Use it to get data about specific objects and filter traffic data. See Work with Object Sets and Work with Traffic correspondingly.
For instance, in the example below, the
memory object of the
Memory type passed to the
dotMemory.Check method contains all memory data in the current execution point. A lambda passed to the
memory.GetObjects method returns a set of objects by a certain condition (all objects of the
In the next example, we create a memory checkpoint before running the user method
Foo.Bar(), then (after the user method finishes working) we create the next checkpoint and assert that traffic between checkpoints haven't exceeded 1000 bytes.
Represents a reference to memory data in some execution point. Use this reference to compare data taken in different execution points or get data about memory traffic between two points. An instance of the
MemoryCheckPoint type is returned by the
dotMemory static class
Returns an instance of the MemoryCheckPoint type which is a reference to memory data in the current execution point. Use this reference as a base for comparison with memory data taken in other points.
Returns a reference to memory data in the current execution point and allows checking these data using Assert statements. The
Represents memory data in some execution point. Object of the
Memory class is used to access memory data with the help of Assert statements. The statements are passed in a lambda expression to the dotMemory.Check method.
(Inherited from ObjectSet)
Gets a subset of objects by a specific condition. The condition is defined by
Returns an instance of the ObjectSet type.
(Inherited from ObjectSet)
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.
Gets difference between the current memory checkpoint and the checkpoint passed in the
Returns an instance of the SnapshotDifference type that allows you to get data about new, dead, and survived objects.
Gets data about memory traffic in the time interval between the current memory snapshot and the snapshot passed in the
Returns an instance of the Traffic type that allows you to get data about objects that were allocated and collected during the specified time interval.