8

The memory management scheme in Windows is very complex, and I'm trying to understand it better so I can diagnose memory problems more accurately.

For example, our C++ application (in SysInternal's Process Explorer) shows 1.4GB "Virtual Size", 400MB "Private Bytes" and 366MB "Working Set".

I did some research and found this question: What is private bytes, virtual bytes, working set?

This is a great read, but some things still don't add up. Specifically, the highest voted answer states that Virtual Bytes includes standby lists. I am not really sure what these are, and any research I've done has yielded less than friendly explanations of it. My biggest question is: How does moving pages to the standby list affect the application's virtual address space (if at all)? In other words, with a virtual size so much bigger than any other size, is the difference fragmented memory?

If anyone can help me understand this a little better I'd greatly appreciate it. Thanks in advance!

Community
  • 1
  • 1
void.pointer
  • 24,859
  • 31
  • 132
  • 243

2 Answers2

9

In a simple scenario, a page that hasn't been used for a while would be removed from a process, cleared and put on a free list, so that any other process could utilize it when more memory's needed.

With a standby list, the page is removed from the process, not modified, and put on a standby list. If the same process happen to need the page, it's returned immediately. If another process needs more memory, the page is cleared and given to that process.

So, in short, the memory manager keeps initialized memory around just in case the process originally using it should want it back - but if someone else wants more memory they'll get it instead.

Erik
  • 88,732
  • 13
  • 198
  • 189
  • So a page moved to standby will never have any open allocations on it (through the C++ memory manager)? – void.pointer Jun 18 '12 at 19:54
  • 3
    @RobertDailey: Yes it may. The C++ memory manager doesn't know nor care whether a backing page is present, on standby, or completely swapped out. When you access the *virtual address* from an application, the OS memory manager will, if needed, map a physical page to that virtual address and, if needed, fill in data from the swapfile. – Erik Jun 18 '12 at 19:57
  • Thanks Erik. Could you explain the "if needed, fill in data from the swapfile" portion? – void.pointer Jun 18 '12 at 21:49
  • It's not that complicated. If the OS needs more memory than physically exists, the extra data is stored on disk, in the swapfile. If a process needs to access some of the data that isn't currently in RAM, that data must be read from the swapfile. This happens automatically, the process can't tell the difference. See http://en.wikipedia.org/wiki/Paging – Harry Johnston Jun 19 '12 at 01:11
  • What is the advantag of putting the page onto the free list compared to just leaving it mapped in? – Florian Wicher Dec 27 '21 at 12:39
0

The standby list is in effect a list of pages of memory that are currently cached, but can be discarded in order to free memory for other applications.

Given that, moving pages to the standby list does not affect the application's virtual address space, as the memory on the list is unclaimed by the process, though the process is able to quickly reclaim it should it need to.

Michael
  • 1,239
  • 9
  • 14
  • 2
    Moving pages to the standby list does never affect virtual address space. It does affect the working set size though. – Erik Jun 18 '12 at 19:33
  • 1
    Come to that, moving a page to the pagefile doesn't change the virtual address space either - the page is still part of the process, it's simply non-resident. – dave Jun 19 '12 at 01:57