我想看一个进程是否有内存泄漏,开始是观察ProcessExplorer里面的WorkingSet,后来发现这个不准确,因为它是物理内存(具体指真正用到的字节数还是页面总共的字节数不清楚),会乱变。查网上,有人说Private Bytes是程序自己分配的,已经提交了的总字节数,且不包含共享内存,这个似乎是我想要的了,可是我发现就算程序处于Idle状态,它也会变化几个字节,按道理它应该只有在我进行操作的时候变化才对。其他的参数Virtual Size, WS Private, WS Sharable and WS shared我也没有找到明确的说明。它们的关系我计算了一下,仅仅有一个确定的:WorkingSet=WS Private+WS Sharable。
有没有人对这些参数的物理意义比较清楚,它们的关系如何?另外不要告诉我用其他方法查内存泄漏,其他方法我了解,我就想知道这几个参数的意义和关系。
有没有人对这些参数的物理意义比较清楚,它们的关系如何?另外不要告诉我用其他方法查内存泄漏,其他方法我了解,我就想知道这几个参数的意义和关系。
Sysinternals Video Library
http://forum.sysinternals.com/forum_posts.asp?TID=11289Topic: Process Explorer - App Memory Consumption
Posted: 03 July 2007 at 4:10am
Hello,
I trying to figure out the memory consumption of my running application using the Process Explorer v10.21.
But I feel that the help it provides is lucking some info.
Can you forward me where I can find a detailed description of the columns of the Process Explorer main window or send my data about it?
The main fields I need to be more familiar with are:
* Private Bytes
* Virtual Size
* Heap Bytes
Does the value of any of them are included in the value of the other?
-----
Thanks
Sharon
Hi, Sharon.
This type of inquiry comes up from time to time. Unfortunately, though it has been discussed I am not aware of any complete comparison or description of the values that Process Explorer or other tools are able to display.
For Virtual Size, the following topic, as well as the link in it, may prove useful:
"Virtual Memory"
For Private Bytes, Microsoft Windows Internals, Fourth Edition states:
the Process: Page File Bytes performance counter is actually the total process private committed memory, of which none, some, or all may be in the paging file. (In fact, it's the same as the Process: Private Bytes performance counter.)
The PE Help File states:
Private Bytes represents the amount of private virtual memory a process has allocated and is the value that will rise of a process exhibiting a memory leak bug.
For Heap Bytes - not sure what you are referring to - the .NET CLR Memory performance counter for "# Bytes in all Heaps"? Per MSDN:
Displays the sum of the Gen 0 Heap Size, Gen 1 Heap Size, Gen 2 Heap Size, and the Large Object Heap Size counters. This counter indicates the current memory allocated in bytes on the garbage collection heaps.
Hope this helps...
Edited by molotov - 03 July 2007 at 5:17am
Daily affirmation:
net helpmsg 4006 mygreenpaste.blogspot.com
据我所知,微软的员工也可以成为MVP。蒋晟有次不是说他跟Bill Gates开会吗?
想查内存泄漏的话,可以自己写内存分配和释放程序,比如MFC的DEBUG_NEW。一些程序会自己分配一个堆,虽然堆上的内存没有被程序的代码使用,但是还是被程序预留了。.Net程序的堆比Visual C++的堆要大,但是一个进程内的所有模块共享一个托管堆,而且GC会避免内存泄漏的问题,但是还没被GC的程序不再使用的对象也会占内存。
如果你要检查内存泄漏,你应该重视private bytes和virtual bytes。如果你的程序的内存页交换太多,你应该检查Working Set。
顺便说一下,你应该用performance monitor来监视性能。你也可以用一个profiler或者注入一个DLL来hook virtualalloc。