<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://blogs.msdn.com/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>The Memory Shell Game</title><link>http://blogs.msdn.com/b/ntdebugging/archive/2007/10/10/the-memory-shell-game.aspx</link><description>Hello, this is Somak. Today I’d like to drop some Memory Manager info on the blog that I’ve used to communicate in brief (believe it or not) how the system deals with memory. If you are ever faced with checking how much Available Memory you have(or don</description><dc:language>en-US</dc:language><generator>Telligent Evolution Platform Developer Build (Build: 5.6.50428.7875)</generator><item><title>re: The Memory Shell Game</title><link>http://blogs.msdn.com/b/ntdebugging/archive/2007/10/10/the-memory-shell-game.aspx#9517429</link><pubDate>Sun, 29 Mar 2009 22:41:41 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9517429</guid><dc:creator>Mel Calucin</dc:creator><description>&lt;P&gt;Thanks for the great post.&lt;/P&gt;
&lt;P&gt;If the Total Physical Memory is way more than the Peak Commit Charge, would there ever be the case where the memory manager will ever need to convert any of the standby page list to zero page list or free page list?&lt;/P&gt;
&lt;P&gt;Also, is there a way to monitor the value of the standby page list without having to install Windows debugger?&lt;/P&gt;
&lt;P&gt;Thanks.&lt;/P&gt;
&lt;DIV class=commentowner&gt;[Yes. The Memory Manager many need to scavenge old pages from the standby list for a variety of reasons. Here are just two examples: 1) Processes starting and stopping - When a process starts, it will get pages from the zero, then the free page list. If there aren’t enough pages, the Memory Manager will pull pages off of the standby list. When a process terminates, its pages will be placed on the free page list. If there is more demand from staring processes than stopping ones, standby pages will be converted. 2) Memory demand from different processes. If some processes have a spike in memory consumption and that demand cannot be met from the free or zero page lists, then the Memory Manager will pull pages from the standby list. Some page churn can be expected as pages change ownership between processes and the system file cache. Typically you won’t notice this as the more used pages tend to remain in working sets or stay long enough on the standby page list to be soft faulted back in.]&lt;/DIV&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9517429" width="1" height="1"&gt;</description></item><item><title>re: The Memory Shell Game</title><link>http://blogs.msdn.com/b/ntdebugging/archive/2007/10/10/the-memory-shell-game.aspx#8584596</link><pubDate>Mon, 09 Jun 2008 12:15:27 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:8584596</guid><dc:creator>Alex Zhdankin</dc:creator><description>&lt;P&gt;Excellent article, thanks! So good, that I have some questions on it:&lt;/P&gt;
&lt;P&gt;"If the process doesn't use the page for a very long time, or if the demand for the page is greater elsewhere, the page is moved off of the standby list."&lt;/P&gt;
&lt;P&gt;1. What does that "very long time" actually mean: 10 seconds, 10 minutes, an hour or a week?&lt;/P&gt;
&lt;P&gt;2. What is the reason to remove standby pages from RAM if there is no need in additional RAM?&lt;/P&gt;
&lt;P&gt;Of course, there might be a demand for more available RAM for other processes in future, but likewise in future these standby pages might be required by the process they belong to.&lt;/P&gt;
&lt;DIV class=commentowner&gt;[Here are the answers to your questions: &lt;BR&gt;&lt;BR&gt;1. Good observation. The working set management algorithm is largely demand based. We try to balance current demand with possible future demand. If there aren't enough free or zeroed pages to meet the system's need, the working set manager will start trimming the least recently used pages. After the zeroed and free pages, we pull from the standby list. If there will never be any future demand, or there are always enough zeroed pages, then the standby list could remain as is. This scenario; however, will most likely never occur. There will always be demand for new pages. Dependent on your system's rate of demand for new pages, older pages on your standby list will be removed. There isn't a fixed time of when your standby page will be scrubbed and passed on, it is just tied system activities like file cache usage, process startup and end and current process memory usages. Given enough time and enough demand for new pages and if the process doesn't soft fault back in the standby page it will be recycled. &lt;BR&gt;&lt;BR&gt;2. If there is no more demand for new pages then we don't remove pages from the standby list. This; however, usually is never the case. You system is almost always doing something with memory. Some processes are requesting new pages, others releasing some. Some processes may be working with cached I/O, other processes could be started or ending. There is always constant churn on the memory pages. Over time, typically you'll see older standby pages removed from the standby list and given to some thread that requested a new page. As long at this page continues to be used, it will remain active for the process. Eventually it may be freed or not used in a long time. If it sits long enough on the standby list, eventually it will most likely be recycled and given to someone else who needs it.]&lt;/DIV&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=8584596" width="1" height="1"&gt;</description></item><item><title>re: The Memory Shell Game</title><link>http://blogs.msdn.com/b/ntdebugging/archive/2007/10/10/the-memory-shell-game.aspx#6940203</link><pubDate>Tue, 01 Jan 2008 21:29:55 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:6940203</guid><dc:creator>David Solomon</dc:creator><description>&lt;P&gt;Some errors in your definitions:&lt;/P&gt;
&lt;P&gt;Committed Memory – "When an application touches a virtual memory page the page becomes a committed page. &amp;nbsp;It is now backed by a physical memory page"&lt;/P&gt;
&lt;P&gt;Not quite: a page becomes a "committed page" when an application commits virtual memory. &amp;nbsp;At that time, the Memory Manager deducts from the system commit limit and charges it to the Commit Charge Total. &amp;nbsp;If and when it is actually touched, then the memory manager backs it with a physical page (that part you had correctly).&lt;/P&gt;
&lt;P&gt;Commit Limit - "If you had 50 applications fully allocate their 2 GB of virtual address space, you would need 100GB of commit limit (ignore kernel memory usage to keep the numbers simple)"&lt;/P&gt;
&lt;P&gt;Not quite: if you had 50 applications fully allocate their 2GB with PRIVATE committed address space, then what you said is true - but if you had 50 apps with 2GB of committed READ ONLY memory (e.g. shared memory or memory mapped files), you would need little or no pagefile space (or RAM) to support this. &amp;nbsp;Again, only private nonshareable process virtual memory counts against the commit limit (not shareable stuff like code in EXEs or DLLs).&lt;/P&gt;
&lt;P&gt;Standby list: "It is still associated with the process, but not in its working set."&lt;/P&gt;
&lt;P&gt;Not quite: it may not be associated with a process if all references to the file have been closed; however, it is still available to a future process that opens and references that cached file data.&lt;/P&gt;
&lt;P&gt;PF Usage is wrong - it is (in Task Manager on XP) *identical* to Commit Charge Total. &amp;nbsp;Your definition (# number of pages that have at one time been pulled out of a process' working set and committed to the page file) is completely off.&lt;/P&gt;
&lt;P&gt;Also, my new instructor Alex Ionescu has a new tool (for Vista and Server 2008 - doesn't run on XP/2003) that shows a superset of system memory information than what the kernel debugger !meminfo shows - and unlike local kernel debugging on Vista which requires booting in Debugging Mode, this tool doesn't require that... see &lt;A href="http://www.alex-ionescu.com/tools.zip" target=_new rel=nofollow&gt;http://www.alex-ionescu.com/tools.zip&lt;/A&gt; (he will be posting a blog post on his site to explain these in the future).&lt;/P&gt;
&lt;DIV class=commentowner&gt;David, Thanks for your feedback. Your clarifications are absolutely correct. The posting was written as a primer for memory manager concepts. It is hard to generalize this complex system. I had to keep the examples simple and brief to easily illustrate the basic concepts. Many things above have some purposefully omitted detail that can be explored further in your book (linked in the articled). Also, thanks for catching the PF Usage error. I’ve updated the definition above. &lt;/DIV&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=6940203" width="1" height="1"&gt;</description></item><item><title>re: The Memory Shell Game</title><link>http://blogs.msdn.com/b/ntdebugging/archive/2007/10/10/the-memory-shell-game.aspx#6923950</link><pubDate>Mon, 31 Dec 2007 23:50:26 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:6923950</guid><dc:creator>Sam Hobbs</dc:creator><description>&lt;P&gt;This article truly is not clear about the relevance of the Commit Charge to performance. It is my understanding that for a specific combination of processes and such in a system, the Commit Charge will be the same regardlous of the amount of physical memory. Some people seem to think that the Commit Charge indicates whether pysical memory is adequate (or correspondingly inadequate) and if it does then I don't understand how Commit Charge is relevant.&lt;/P&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=6923950" width="1" height="1"&gt;</description></item><item><title>re: The Memory Shell Game</title><link>http://blogs.msdn.com/b/ntdebugging/archive/2007/10/10/the-memory-shell-game.aspx#6923771</link><pubDate>Mon, 31 Dec 2007 23:35:32 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:6923771</guid><dc:creator>Sam Hobbs</dc:creator><description>&lt;P&gt;It is my understanding that executables (exe and dll files) are mapped into virtual storage but not all of them are always read into physical memory.&lt;/P&gt;
&lt;P&gt;It is not clear to me whether the executables are read into memory and then written to the pagefile, but that seems inconsistent with my understanding.&lt;/P&gt;
&lt;P&gt;So I don't understand enough of this issue to ask a good question, but I suspect it is something that needs clarification.&lt;/P&gt;
&lt;DIV class=commentowner&gt;Great questions! If multiple process load the same DLL (like ntdll.dll), it isn’t efficient to load the file multiple times. Modern day operating systems load executable modules (exe or dll) in shared memory. The virtual page in each process where the module is loaded will point to the same shared section for the module. This way only one instance of the module is loaded. Each process will maintain its own private data (for globals and such) and use the shared pages for static and unmodified pages in the module. When the module’s pages are removed from working sets, the page is not committed to the page file. These pages are backed by the file on disk, so it doesn’t make sense to save a copy to the page file as well. Basically we remove the page from physical memory. A hard fault to one of these pages will be resolved from the file on disk. If a process modified module globals or data structures, those pages would be converted to private committed and would be backed by the page file. &lt;/DIV&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=6923771" width="1" height="1"&gt;</description></item><item><title>Too Much Cache?</title><link>http://blogs.msdn.com/b/ntdebugging/archive/2007/10/10/the-memory-shell-game.aspx#6554807</link><pubDate>Tue, 27 Nov 2007 19:48:51 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:6554807</guid><dc:creator>Noticias externas</dc:creator><description>&lt;p&gt;Cache is used to reduce the performance impact when accessing data that resides on slower storage media&lt;/p&gt;
&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=6554807" width="1" height="1"&gt;</description></item><item><title>Too Much Cache?</title><link>http://blogs.msdn.com/b/ntdebugging/archive/2007/10/10/the-memory-shell-game.aspx#6553529</link><pubDate>Tue, 27 Nov 2007 18:46:25 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:6553529</guid><dc:creator>Microsoft Advanced Windows Debugging and Troubleshooting</dc:creator><description>&lt;p&gt;Cache is used to reduce the performance impact when accessing data that resides on slower storage media.&amp;amp;#160;&lt;/p&gt;
&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=6553529" width="1" height="1"&gt;</description></item><item><title>re: The Memory Shell Game</title><link>http://blogs.msdn.com/b/ntdebugging/archive/2007/10/10/the-memory-shell-game.aspx#5943954</link><pubDate>Wed, 07 Nov 2007 00:19:17 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:5943954</guid><dc:creator>Attila</dc:creator><description>&lt;p&gt;If the the os gets hibernated, the standby pages are written to the hiberfil.sys?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=5943954" width="1" height="1"&gt;</description></item><item><title>re: The Memory Shell Game</title><link>http://blogs.msdn.com/b/ntdebugging/archive/2007/10/10/the-memory-shell-game.aspx#5885554</link><pubDate>Sun, 04 Nov 2007 17:19:25 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:5885554</guid><dc:creator>Saurabh</dc:creator><description>&lt;p&gt;Indeed, a very good article. Such a complex topic written in a very lucid elegant way...thanks so much.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=5885554" width="1" height="1"&gt;</description></item><item><title>re: The Memory Shell Game</title><link>http://blogs.msdn.com/b/ntdebugging/archive/2007/10/10/the-memory-shell-game.aspx#5474391</link><pubDate>Tue, 16 Oct 2007 22:20:15 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:5474391</guid><dc:creator>A Santa Monica</dc:creator><description>&lt;P&gt;Very good article.&lt;/P&gt;
&lt;P&gt;Very good reference to Windows Internals as well.&lt;/P&gt;
&lt;P&gt;Thank you for writing.&lt;/P&gt;
&lt;P&gt;It might be a rather naive question but I would like to understand how it is implemented the hierarchical access time for those pools.&lt;/P&gt;
&lt;P&gt;I mean, I suppose accessing the standby page´s pool 'takes lesser' then acessing free page´s pool or zeroed page´s pool and that acessing all the three pools 'takes longer' than accessing the pages on the working set.&lt;/P&gt;
&lt;P&gt;Is it only because of the calls and context switching(efforts) that would take a process to request the memory manager to grab those pages(which are not on its working set space) or there are other reasons like the design of those particular pools(and here I am thinking of pools as queues and the different approaches one might implement for acessing queues and serializing/parallelizing access strategies).&lt;/P&gt;
&lt;P&gt;See, I dont quite get it what makes the standy pages more quickly acessible in opposite to free pages or zeroed pages, for instance.&lt;/P&gt;
&lt;P&gt;Since they are all on the same physical memory and no concepts such as NUMA are appliable.&lt;/P&gt;
&lt;P&gt;Thank you once again.&lt;/P&gt;
&lt;DIV class=commentowner&gt;[The access time for a page in the process’ working set will be the fastest. If a page leaves the process’ working set, it is placed on to the standby list. If a thread accesses the page when it is on the standby list, the thread will encounter a trivial delay. A page fault exception occurs and is handled by the memory manager. No context switch occurs for this operation. This soft fault will require some CPU cycles and a few access requests to physical RAM. The performance hit for this soft fault is so small; you will probably never notice it. I have only heard of one high performance application being affected by this, but I never saw any performance data to validate this claim. The application probably accessed its pages poorly and perhaps could have benefited from locking some of its critical pages into physical memory. &lt;BR&gt;&lt;BR&gt;When a process requests a new page, transitioning from the zero page list will be the fastest. After that is transition from the free list to the zero page list. This transition requires a page scrub. This is bound by the speed and bandwidth of your physical RAM. There is no context switch here as well. Once again, these are very small performance hits. Chances are that you’ll never notice the hit from this operation. I hope this answers your questions.] &lt;/DIV&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=5474391" width="1" height="1"&gt;</description></item></channel></rss>