God's in his heaven.
All's right with the world.


(Stack Overflow) When does Windows decide to pull out pages from Working Set?


I am looking at the distribution of physical memory using the RAMMap tool by SysInternals. The distribution (see image below) shows

  1. 7 GB in Free (Zeroed) memory list
  2. 2 GB in Working Set list
  3. 550 MB in Standby list
  4. 125 MB in Modified list

I understand that when a process requires memory, Windows searches for memory in the lists in the order Free (Zeroed) -> Standby -> Modified. Hence, as long as we have Free page frames, everything should either be in the Working Set list or Free list.

  1. Is this assumption right?
  2. If so, why do we see 125 MB of pages in the Modified list?
  3. In general, when does Windows decide to pull out pages from Working set list to Modified/Standby list even when there is Free memory left?

I am using Windows 7, with 4.0 GB of installed RAM, 3.5 GB being usable.

Answer by Rick Brant

No. If a page is going to be read from disk, or if it’s an allocation from kernel mode, the free list is checked first, then the zeroed list. If it isn’t, the zeroed list is checked first, then the free list (if allocated from the free list the page will be zeroed in-line before the faulting process gets to see it). In both cases, the standby list comes next. I don’t believe the modified list is ever used to satisfy page faults… since the pages have to be written out to disk before they can be assigned to other uses… so, might as well wait for the modified page writer to do its regular thing, whereupon the pages will show up on the standby list.
1a. “As long as we have free page frames, everything should either be in the working set list or free list.” No. The standby list is considered “available” but until someone needs that RAM its pages are used for two different types of caches.

The second question (stupid automatic list formatting keeps starting over at “1” here): That’s rather a lot. Did you delete your pagefile?

The third question: First, keep in mind that there is a working set list for every process, not just one. And each has its own “limit”. When the limits are being enforced (they aren’t if there is plenty of free RAM), the process has to give up a page for every new page it faults in. There is also a working set reclamation process that tries to shrink long-idle processes.

When a process loses a page, it goes on the modified list if it was touched with a “modify”-style operand while it was in the working set, or on the standby list if not. If the process later faults to the page before it is assigned to some other use or process, it can be brought back into the process working set without going to disk for it. (This is a common example of a “soft” page fault.) In this way these lists form a sort of common system-wide extension to all processes’ working sets. But everything on the Standby list is still counted as part of “Available” memory, because it can be used by any other process immediately - noting has to be written out to disk.

Starting with Vista, there is a new concept called memory priority. Pages on the standby list that are of low priority can be reassigned for use by the new proactive file cache, SuperFetch. But this doesn’t cost any “available” RAM because they’re still on the standby list. (The old reactive cache is still there; it used to be part of the system working set; as of Windows 7 it has its own.)

This is but the tip of the iceberg. The Mm chapter of Windows Internals is 200 pages long, enough for a smallish book all by itself. But if you really want to understand this stuff, there isn’t really a substitute.

Article link: http://xnerv.wang/when-does-windows-decide-to-pull-out-pages-from-working-set/
Reprinted from: (StackOverflow) When does Windows decide to pull out pages from Working Set?