dotMemory Unit 2.4 Help

Configuring dotMemory Unit

The default dotMemory Unit configuration allows using it “out of the box”. Nevertheless, in some cases you may want to redefine particular options like workspace files location or total size limit for auto-saved workspaces. This is done with the help of DotMemoryUnitAttribute placed before an assembly, a test class, or a test method.

Example

[DotMemoryUnit(SavingStrategy = SavingStrategy.OnCheckFail, Directory = @"C:\tmp\Method")] [Test] public void TestMethod1() { ... }

DotMemoryUnitAttribute

DotMemoryUnitAttribute properties

NameTypeDescription
CollectAllocations bool Defines whether the memory allocation data (memory traffic and creation stack trace data) must be collected. By default, false. Collecting allocation data significantly increases the profiling overhead. Use it only if you need to measure the amount of memory traffic.
Note that the AssertTraffic attribute enables collecting allocations in the marked method automatically. You do not need to add the [DotMemoryUnit(CollectAllocations = true)] attribute in this case.
Directory string Path to the directory where workspace files must be saved. This can be either a full path or a path relative to the assembly where the test method is declared. Note that for simplicity, you can use a number of placeholders for special directories:
  • <User> - current user folder, e.g. C:\Users\[username]
  • <LocalAppData> - local application data folder, e.g. C:\Users\[username]\AppData\Local
  • <CommonAppData> - program data folder, e.g. C:\ProgramData
DiskSpaceLimit int Maximum disk size in bytes that can be used for storing workspaces. The default value is 200 MB. Before saving a workspace, dotMemory Unit checks the total size of all previously saved workspaces in the session. If the limit is not yet exceeded, the workspace will be saved (even if this will exceed the limit).
FailIfRunWithoutSupport bool If false, all dotMemory.Check calls will be ignored in case a test is run without the support for dotMemory Unit.
If true, the test containing dotMemory.Check calls will fail in case this test is run without the support for dotMemory Unit.
The default value is true.
SavingStrategy SavingStrategy
enum
{OnAnyFail, OnCheckFail, Never}
Defines conditions for auto-saving workspaces:
  • OnAnyFail - Auto-save workspace on any test failure.
  • OnCheckFail - Auto-save workspace on dotMemory.Check call failure.
  • Never - Do not auto-save workspaces.
WorkspaceNumberLimit int Maximum number of workspaces that can be saved upon test failures. The default value is 5.
Last modified: 26 October 2017