dotMemory Unit 3.2 Help

Work with Traffic

In terms of dotMemory, memory traffic is an integral estimate of how many objects were allocated and collected on a time interval. Large traffic affects app performance as garbage collections imply significant CPU overhead. dotMemory Unit offers two ways of checking memory traffic:

  • Using the AssertTraffic attribute for simple assertions. For example, when you just need to assert that traffic in a test doesn't exceed some value.

  • Using the Traffic class for more complex assertions. For example, check traffic of objects of a particular type on some specific time interval.

Collect memory allocation data

By default, due to performance considerations, memory allocation data (memory traffic and stack trace data) are not collected by the profiler. Therefore, if your tests analyze traffic data, you should manually turn on the collecting of memory allocation data for an assembly, a test class, or a specific test. The AssertTraffic attribute does this automatically. In more complex cases, when you do not use the AssertTraffic attribute, apply the [DotMemoryUnit(CollectAllocations=true)] attribute. For more examples, refer to Collect Allocation Data.

Last modified: 05 September 2023