Introduction
.NET Memory Profiler is a tool for the .NET Common Language Runtime that allows the user to retrieve information about all instance allocations performed on the garbage collected heap (GC heap) and all instances that reside on the GC heap. The retrieved information is presented in real time, both numerically and graphically.
The real-time information presented gives a good overview of the activity and status of the GC heap, but by collecting snapshots of the heap, very detailed information can be presented. Information is provided about: all managed types, all instances of types, the call stacks of the instance allocations, and the path to a root from each instance. An instance graph can be presented for a set of instances or a specific instance, giving a visual overview of how the instances are used and how they are related to other instances.
It is possible to compare two snapshots, which is a very convenient and efficient way of detecting memory leaks in a program. The memory profiler also helps to locate sections of the program that perform excessive allocations.
The automatic memory analyzer provides tips and warnings regarding common memory usage issues, making it easier to locate potential memory leaks and optimize memory and resources usage.
The profiler contains a dispose tracker, which provides additional data about disposable instances (i.e. instances of classes implementing IDisposable), and a heap utilization tracker, which gives information about how the heap memory is utilized.
In addition to presenting information about the GC heap, the profiler also presents information about the native memory of the profiled process or any other process running on the computer.
An API is available that can be used to programmatically check for memory leaks. Combined with the possibility to run the profiler without a user interface, e.g. using the NmpCore tool or the NmpCore task, this API can be used to perform fully automated memory testing.
The professional edition of .NET Memory Profiler includes additional features such as the native resources tracker, the “attach to” function, the possibility to import memory dump files, profiler projects, and peak snapshots.
The enterprise edition includes further features such as better support for multi-process profiling, remote profiling, and running unit tests under the profiler.
The resource tracker allows the profiler to present detailed information about native resources, such as heap memory, bitmaps and windows.
The “attach to” function and the possibility to import memory dump files make it much easier to investigate memory issues on production systems where it might not be possible to use the profiler directly.
A .NET Memory Profiler project allows all settings used to profile a process to be saved, making it easier to use different settings for different applications. It also keeps track of session files related to the project, allowing the user to compare snapshots between different sessions. This is particularly useful when doing automated testing and the user wants to check whether the memory usage has changed between different builds of a program.