原文:http://stackoverflow.com/questions/1984186/what-is-private-bytes-virtual-bytes-working-set
The short answer to this question is that none of these values are a reliable indicator of how much memory an executable is actually using, and none of them are really appropriate for debugging a memory leak.
Private Bytes refer to the amount of memory that the process executable has asked for - not necessarily the amount it is actually using. They are "private" because they (usually) exclude memory-mapped files (i.e. shared DLLs). But - here's the catch - they don't necessarily exclude memory allocated by those files. There is no way to tell whether a change in private bytes was due to the executable itself, or due to a linked library. Private bytes are also not exclusively physical memory; they can be paged to disk or in the standby page list (i.e. no longer in use, but not paged yet either).
Working Set refers to the total physical memory (RAM) used by the process. However, unlike private bytes, this also includes memory-mapped files and various other resources, so it's an even less accurate measurement than the private bytes. This is the same value that gets reported in Task Manager's "Mem Usage" and has been the source of endless amounts of confusion in recent years. Memory in the Working Set is "physical" in the sense that it can be addressed without a page fault; however, the standby page list is also still physically in memory but not reported in the Working Set, and this is why you might see the "Mem Usage" suddenly drop when you minimize an application.
Virtual Bytes are the total virtual address space occupied by the entire process. This is like the working set, in the sense that it includes memory-mapped files (shared DLLs), but it also includes data in the standby list and data that has already been paged out and is sitting in a pagefile on disk somewhere. The total virtual bytes used by every process on a system under heavy load will add up to significantly more memory than the machine actually has.
So the relationships are:
- Private Bytes are what your app has actually allocated, but include pagefile usage;
- Working Set is the non-paged Private Bytes plus memory-mapped files;
- Virtual Bytes are the Working Set plus paged Private Bytes and standby list.
There's another problem here; just as shared libraries can allocate memory inside your application module, leading to potential false positives reported in your app's Private Bytes, your application may also end up allocating memory inside the shared modules, leading to false negatives. That means it's actually possible for your application to have a memory leak that never manifests itself in the Private Bytes at all. Unlikely, but possible.
Private Bytes are a reasonable approximation of the amount of memory your executable is using and can be used to help narrow down a list of potential candidates for a memory leak; if you see the number growing and growing constantly and endlessly, you would want to check that process for a leak. This cannot, however, prove that there is or is not a leak.
One of the most effective tools for detecting/correcting memory leaks in Windows is actually Visual Studio(link goes to page on using VS for memory leaks, not the product page). Rational Purify is another possibility. Microsoft also has a more general best practices document on this subject. There are more tools listed in this previous question.
I hope this clears a few things up! Tracking down memory leaks is one of the most difficult things to do in debugging. Good luck.
相关推荐
性能监控器 内存 Available Mbytes (NON) Paged Pool bytes Free System PTE Private Bytes/Virtual Bytes/Working Set
Virtual Private LAN Services (VPLS) uses the provider core to join multiple attachment circuits together to simulate a virtual bridge that connects the multiple attachment circuits together . From a ...
Amazon Virtual Private Cloud Connectivity Options,可以帮助AWS用户设计适合的网络安全架构,特别是帮助用户提升网络安全纵深防御的能力,在云上网络VPC的安全设计是基础也是云安全的能力框架中第二重要的因素
Amazon Virtual Private Cloud VPC Peering Guide--- AWS
稳定的代理软件,window客户端使用,不支持自动寻找代理服务器
Introduce to Microsoft Virtual Machine Manager 2008 R2 in Private Cloud
The system working set is represented by the counter Memory: cache bytes. System working set paging activity can be viewed by monitoring the Memory: Cache Faults/sec counter. For more information, ...
听写-Solving Private Set Intersection1
private,public,protected,还有default四种之间的区别private,public,protected,还有default四种之间的区别
wiz-private wiz-private
Scalable Multi-Party Private Set-Intersection-解读.doc
PRIVATE
private
请勿用于商业用途!请勿用作非法用途!官方版本有30天的免费试用期,请大家支持正版,此版本仅供个人学习交流,对于造成的问题,本作者概不负责! ...privateKey.bytes publicKey.bytes readme.txt
Private Shell。Private Shell。Private Shell。Private Shell。
Oculus First Private View with Virtual Reality 基于 Oculus Tiny,使用 VC++、Xbee、Arduino Tech Set。 真实图像是通过立体摄像头拍摄的,Oculus HMD 会显示这些图像。 ##指数 Visual C++ 和 DirectX HLSL ...
invokespecial and Private Methods invokespecial and super The invokeinterface Instruction Invocation Instructions and Speed Examples of Method Invocation Returning from Methods On the CD-ROM ...
public private protest super final abstract this 等用法
MT4/MT5外汇交易VPS(Virtual Private Server 虚拟专用服务器)技术 伴随着国内EA智能交易的兴起,VPS技术在外汇零售交易领域的应用也在逐渐扩大,那么什么是VPS技术?它又能带给交易者怎样的好处? 【什么是VPS】 VPS...
private doc private doc