MSDN中关于Working Set的一些说明

*The working set of a process is the set of memory pages currently visible to the process in physical RAM memory. These pages are resident and available for an application to use without triggering a page fault. 
*The working set of a process consists of the set of resident physical pages visible to the process. When a thread accesses a page that is not in the working set of its process, a page fault occurs. Before the thread can continue, the virtual memory manager must add the page to the working set of the process. A larger working set increases the probability that a page will be resident in memory, and decreases the rate of page faults.

可以把Working Set看成一个进程可以用到(但不一定会使用)的物理内存(物理内存页的集合)。内存管理单元在进行虚拟内存地址到物理内存地址转换时,如果虚拟地址不在物理内存中,会引起page fault异常。足够的WorkingSet就可以保证常用的虚拟地址都位于物理内存中,减少这种异常,避免了异常处理(例如访问swap文件,将页面读入物理内存)带来的性能损耗。因此,对于时间比较敏感的程序,应该分配足够的WorkingSet以保证程序性能。
 
*When you increase the working set size of an application, you are taking away physical memory from the rest of the system.
*Suppose you have a 16-megabyte system and you set your minimum to four megabytes. In effect, this takes away four megabytes from the system. Other applications may be unable to get their minimum working set.

可见,Working Set是被真实地从物理内存中划分出来的。一个程序占用了多少Working Set,物理内存中就有多少空间不能被其它程序使用。
 
*Reducing memory consumption is always a beneficial goal. If you call SetProcessWorkingSetSize(0xffffffff, 0xffffffff), this tells the system that your working set can be released. This does not change the current sizing of the working set, it just allows the memory to be used by other applications. It is a good idea to do this when your application goes into a wait state. 
*Windows NT 3.5 allows processes to increase their working set size by using SetProcessWorkingSetSize(). This API is also useful to trim your minimum working set size if you want to run many processes at once, because each process has the default minimum working set size reserved, no matter how small the process actually is.

Windows会为每个进程保留一个默认数值的working set,然而这个保留的Working set可能会比该process实际需要的大。可以用SetProcessWorkingSetSize()来对进程的Working set进行裁剪,只保留进程目前已经占用的页面,空闲的就释放掉给其它应用使用。
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值