You can use the API exposed by ANTS Memory Profiler to take snapshots from within your code. First, you need to edit your application's code to trigger the snapshot, then run the built application alongside ANTS Memory Profiler.
Take snapshots from your code to ensure that snapshots are taken precisely when you believe that a leak occurs, or if your application does not have an interface through which you can control it. The snapshot API lets you essentially automate the process of taking a snapshot.
If your application is a Silverlight browser application, you cannot use the snapshot API. (This is due to security restrictions in Silverlight.)
RedGate.MemoryProfiler.Snapshot.TakeSnapshot()whenever you want to take a snapshot. This method returns
trueon success and
falseon failure. To take a snapshot and give it a memorable name at the same time, provide a string argument to the
TakeSnapshotmethod, for example:
We recommend that you contain the
TakeSnapshot() method within a
try-catch statement. This is because
TakeSnapshot() can raise exceptions, for example if it is called more than 5 times in 30 seconds.