While dotMemory 4.4 is primarily focused on dotMemory Unit 2.0, it also brings a number of useful updates. One such improvement is the ability to take memory snapshots only when a certain condition occurs. The most common use case for this is taking a snapshot when the memory consumption in your application increases dramatically. As catching the moment manually (using the Get Snapshot button) may be quite tricky, dotMemory 4.4 allows you to automate the process.
All you need to do is set a particular condition, such as:
- Memory consumption increase in MB
- Memory consumption increase in %
- Period of time in minutes (periodical taking of snapshots)
After the condition occurs, the snapshot will be collected automatically.
For example, let’s say we have a web application that allocates a huge amount of memory after some actions (but we’re not sure of their exact sequence). What is the root cause? Is this some ineffective algorithm or just IIS that reserves memory for hard times? In this case, the best solution is to attach dotMemory to the app pool that runs the application and take a memory snapshot when memory consumption surges. As we don’t want to spend all day waiting for this moment, we will add the condition on taking the snapshot.
- Attach dotMemory to the corresponding app pool (w3wp.exe process).
- As soon as the session starts, click Get Snapshot By Condition.
- In the Get Snapshot by Condition window, specify the condition for taking a snapshot. In our case, we will take snapshot if memory consumption increases by 100 MB. The maximum number of snapshots that can be taken automatically is set by the Limit the max number of snapshots to parameter.
That’s it! As soon as we click Start, dotMemory will track overall application memory usage. When it exceeds the current value (taken at the time of clicking Start) by 100 MB, dotMemory will take a snapshot, all on its own!
Note that, as soon as the defined condition occurs, the memory consumption at that moment becomes the new baseline.