dotMemory Unit
 
Get dotMemory Unit

Alternative Way to Work with Memory

Last modified: 23 August 2023

If you don't want to work with memory in a way described in Work with Memory, you have an alternative. We don't hide the "kernel" level of the framework which is based on the dotMemoryApi static class. This class allows you to directly work with memory snapshots without using lambdas. Actually, the dotMemory.Check method is a wrapper of dotMemoryApi calls.

You can use the dotMemoryApi class to write your own wrapper or directly work with memory snapshots.

In the latter case, you should keep in mind the following peculiarities:

  • Taking a snapshot may be a time-consuming operation.

  • Snapshots contain memory data on the moment you take them, not on the moment you access them.

  • In case of errors in the test code, test runner will be unable to distinguish whether the test fails because of a dotMemory Unit call or other test code.

  • All dotMemory Unit calls should be preceded by the check on whether support for dotMemory Unit is enabled.

For example, the following assertion

can be rewritten as