Working 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. E.g., when you just need to assert that traffic in a test doesn't exceed some value.
- Using the Traffic class for more complex assertions. E.g., check traffic of objects of a particular type on some specific time interval.
Collecting 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. See Turning On Collecting of Allocation Data for examples.