Total size of all objects does not match the memory footprint of an application
Published 14 May 2018
There is usually a disparity between the total size of all objects allocated on the managed heap (reported by ANTS Memory Profiler) and the amount of memory shown to be used by the entire process, for example the memory shown in Windows Task Manager.
This is not a bug in ANTS Memory Profiler, but rather a difference in the type of memory being tracked by ANTS Memory Profiler.
The total memory used by a .NET application comprises:
- the application image itself
- the .NET runtime
- any application extensions (dlls) loaded by the process being profiled.
These items are not tracked by ANTS Profiler and therefore are not reflected in the results.
Additionally, .NET memory management typically allocates more heap memory than what is actually requested by your application. Because memory allocation is expensive, .NET will request extra memory for the managed heap and work inside this memory rather than continually requesting more memory from the operating system in smaller increments. For this reason, even the process managed heap size reported by the ".NET CLR Memory" performance object may be larger than what is reported by ANTS Memory Profiler.
In order to see really specific usage information about the memory of a process, the most accurate way is to use a debugger. Redgate have produced a free tool that graphically displays a .NET application's memory space. Memory Tracker can illustrate some of the memory issues discussed in this article. You may download this tool from Redgate Labs