0

我正在使用 DebugDiag 1.2 和 perfmon.exe 来监视 .NET 应用程序的内存使用情况。

DebugDiag 显示GC Heap Size为 35.51 MB,而对于同一时刻 perfmon 显示#Bytes in all heaps为 4.5 MB。

为什么两个值不同?它们代表的不是同一个东西吗?

4

1 回答 1

2

"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

于 2014-01-18T11:49:56.663 回答