Checking for Objects
Checking for objects of a specific type
Checking for objects of a specific type is the main way of finding memory leaks in your code.
A lambda is passed to the
Checkmethod of the static dotMemory type. What this method does is takes a dump of the managed heap. This method will be called only in case you run the test using Run test under dotMemory Unit.
memoryobject of the Memory type passed to the lambda contains all memory data for the current execution point.
The GetObjects method returns a set of objects that match the condition passed in another lambda. E.g., what this line does is slices the memory by leaving only objects of the
Gootype. The NUnit
Assertexpression asserts that there should be 0 objects of the
Selecting objects by a number of conditions
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:
dotMemory Unit also provides alternative syntax for object set queries. You can use the
| logic operators to combine a number of queries. For example:
Note that open generic types and interfaces are also supported. For example: