I am using DebugDiag 1.2 and perfmon.exe to monitor memory usage for a .NET application.
DebugDiag shows the GC Heap Size
as 35.51 MB, while for the same instant perfmon shows the #Bytes in all heaps
as 4.5 MB.
Why are both values different ? Dont they represent the same thing ?
"Bytes in all heaps" represents memory used by all the .NET objects which are currently in use by the application where as GC Heap size is actually the memory committed in the .NET heap. The reason why GC heap size will be greater is because it includes the memory used by the objects that are marked as "FREE". .NET does not immediately return back all the memory that is marked as FREE back to the OS and that is freed on the next garbage collection so that memory is still marked as commit and is still in .net heap but not really in use by anything in the application.
To get more understanding of this please go through http://blogs.msdn.com/b/tess/archive/2005/11/25/496973.aspx and search for the word Free in that blog