MSDN中关于Working Set的一些阐明sohu - 牛牛娱乐

MSDN中关于Working Set的一些阐明sohu

2019-02-08 09:04:38 | 作者: 冰绿 | 标签: 物理,内存,进程 | 浏览: 3184

*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进行裁剪,只保存进程现在现已占用的页面,闲暇的就释放掉给其它运用运用。