dotMemory Unit 2.4 Help

Simple Scenarios. AssertTraffic Attribute

For simple assertions about traffic, you can use the AssertTraffic attribute. It allows you to assert that a test allocates less than a specific number of objects or memory amount.
The main limitation of such an approach is that traffic is calculated for the entire unit test and only for allocated objects. Thus, if you want to check traffic on a specific time interval or make assertions about collected objects, you should use the Traffic type.

You can add any number of AssertTraffic attributes in case you want to filter traffic by a number of conditions.


// Assert the test allocates no more than 1000 strings [AssertTraffic(AllocatedObjectsCount = 1000, Types = new[] {typeof(string)})] [Test] public void TestMethod1() { ... }

AssertTraffic properties

AllocatedSizeInBytes long Asserts the size of allocated objects in bytes.
AllocatedObjectsCount int Asserts the number of allocated objects.
Types Type[] Selects objects for assertions by type.
Interfaces Type[] Selects objects for assertions by implemented interface.
Namespaces string[] Selects objects for assertions by namespace *.
The asterisk (*) wildcard is supported.
Last modified: 26 October 2017