다음을 통해 공유


Pushing the Limits of Windows: Virtual Memory

In my first Pushing the Limits of Windows post, I discussed physical memory limits, including the limits imposed by licensing, implementation, and driver compatibility. Here’s the index of the entire Pushing the Limits series. While they can stand on their own, they assume that you read them in order.

Pushing the Limits of Windows: Physical Memory

Pushing the Limits of Windows: Virtual Memory

Pushing the Limits of Windows: Paged and Nonpaged Pool

Pushing the Limits of Windows: Processes and Threads

Pushing the Limits of Windows: Handles

Pushing the Limits of Windows: USER and GDI Objects – Part 1

Pushing the Limits of Windows: USER and GDI Objects – Part 2

This time I’m turning my attention to another fundamental resource, virtual memory. Virtual memory separates a program’s view of memory from the system’s physical memory, so an operating system decides when and if to store the program’s code and data in physical memory and when to store it in a file. The major advantage of virtual memory is that it allows more processes to execute concurrently than might otherwise fit in physical memory.

While virtual memory has limits that are related to physical memory limits, virtual memory has limits that derive from different sources and that are different depending on the consumer. For example, there are virtual memory limits that apply to individual processes that run applications, the operating system, and for the system as a whole. It's important to remember as you read this that virtual memory, as the name implies, has no direct connection with physical memory. Windows assigning the file cache a certain amount of virtual memory does not dictate how much file data it actually caches in physical memory; it can be any amount from none to more than the amount that's addressable via virtual memory.

Process Address Spaces

Each process has its own virtual memory, called an address space, into which it maps the code that it executes and the data that the code references and manipulates. A 32-bit process uses 32-bit virtual memory address pointers, which creates an absolute upper limit of 4GB (2^32) for the amount of virtual memory that a 32-bit process can address. However, so that the operating system can reference its own code and data and the code and data of the currently-executing process without changing address spaces, the operating system makes its virtual memory visible in the address space of every process. By default, 32-bit versions of Windows split the process address space evenly between the system and the active process, creating a limit of 2GB for each:

 image

Applications might use Heap APIs, the .NET garbage collector, or the C runtime malloc library to allocate virtual memory, but under the hood all of these rely on the VirtualAlloc API. When an application runs out of address space then VirtualAlloc, and therefore the memory managers layered on top of it, return errors (represented by a NULL address). The Testlimit utility, which I wrote for the 4th Edition of Windows Internals to demonstrate various Windows limits,  calls VirtualAlloc repeatedly until it gets an error when you specify the –r switch. Thus, when you run the 32-bit version of Testlimit on 32-bit Windows, it will consume the entire 2GB of its address space:

image

2010 MB isn’t quite 2GB, but Testlimit’s other code and data, including its executable and system DLLs, account for the difference. You can see the total amount of address space it’s consumed by looking at its Virtual Size in Process Explorer:

image

Some applications, like SQL Server and Active Directory, manage large data structures and perform better the more that they can load into their address space at the same time. Windows NT 4 SP3 therefore introduced a boot option, /3GB, that gives a process 3GB of its 4GB address space by reducing the size of the system address space to 1GB, and Windows XP and Windows Server 2003 introduced the /userva option that moves the split anywhere between 2GB and 3GB:

 image

To take advantage of the address space above the 2GB line, however, a process must have the ‘large address space aware’ flag set in its executable image. Access to the additional virtual memory is opt-in because some applications have assumed that they’d be given at most 2GB of the address space. Since the high bit of a pointer referencing an address below 2GB is always zero, they would use the high bit in their pointers as a flag for their own data, clearing it of course before referencing the data. If they ran with a 3GB address space they would inadvertently truncate pointers that have values greater than 2GB, causing program errors including possible data corruption.

All Microsoft server products and data intensive executables in Windows are marked with the large address space awareness flag, including Chkdsk.exe, Lsass.exe (which hosts Active Directory services on a domain controller), Smss.exe (the session manager), and Esentutl.exe (the Active Directory Jet database repair tool). You can see whether an image has the flag with the Dumpbin utility, which comes with Visual Studio:

image

Testlimit is also marked large-address aware, so if you run it with the –r switch when booted with the 3GB of user address space, you’ll see something like this:

image

Because the address space on 64-bit Windows is much larger than 4GB, something I’ll describe shortly, Windows can give 32-bit processes the maximum 4GB that they can address and use the rest for the operating system’s virtual memory. If you run Testlimit on 64-bit Windows, you’ll see it consume the entire 32-bit addressable address space:

image

64-bit processes use 64-bit pointers, so their theoretical maximum address space is 16 exabytes (2^64). However, Windows doesn’t divide the address space evenly between the active process and the system, but instead defines a region in the address space for the process and others for various system memory resources, like system page table entries (PTEs), the file cache, and paged and non-paged pools.

The size of the process address space is different on IA64 and x64 versions of Windows where the sizes were chosen by balancing what applications need against the memory costs of the overhead (page table pages and translation lookaside buffer - TLB - entries) needed to support the address space. On x64, that’s 8192GB (8TB) and on IA64 it’s 7168GB (7TB - the 1TB difference from x64 comes from the fact that the top level page directory on IA64 reserves slots for Wow64 mappings). On both IA64 and x64 versions of Windows, the size of the various resource address space regions is 128GB (e.g. non-paged pool is assigned 128GB of the address space), with the exception of the file cache, which is assigned 1TB. The address space of a 64-bit process therefore looks something like this:

image

The figure isn’t drawn to scale, because even 8TB, much less 128GB, would be a small sliver. Suffice it to say that like our universe, there’s a lot of emptiness in the address space of a 64-bit process.

When you run the 64-bit version of Testlimit (Testlimit64) on 64-bit Windows with the –r switch, you’ll see it consume 8TB, which is the size of the part of the address space it can manage:

image

image 

Committed Memory

Testlimit’s –r switch has it reserve virtual memory, but not actually commit it. Reserved virtual memory can’t actually store data or code, but applications sometimes use a reservation to create a large block of virtual memory and then commit it as needed to ensure that the committed memory is contiguous in the address space. When a process commits a region of virtual memory, the operating system guarantees that it can maintain all the data the process stores in the memory either in physical memory or on disk.  That means that a process can run up against another limit: the commit limit.

As you’d expect from the description of the commit guarantee, the commit limit is the sum of physical memory and the sizes of the paging files. In reality, not quite all of physical memory counts toward the commit limit since the operating system reserves part of physical memory for its own use. The amount of committed virtual memory for all the active processes, called the current commit charge, cannot exceed the system commit limit. When the commit limit is reached, virtual allocations that commit memory fail. That means that even a standard 32-bit process may get virtual memory allocation failures before it hits the 2GB address space limit.

The current commit charge and commit limit is tracked by Process Explorer in its System Information window in the Commit Charge section and in the Commit History bar chart and graph:

image  image

Task Manager prior to Vista and Windows Server 2008 shows the current commit charge and limit similarly, but calls the current commit charge "PF Usage" in its graph:

image

On Vista and Server 2008, Task Manager doesn't show the commit charge graph and labels the current commit charge and limit values with "Page File" (despite the fact that they will be non-zero values even if you have no paging file):

image

You can stress the commit limit by running Testlimit with the -m switch, which directs it to allocate committed memory. The 32-bit version of Testlimit may or may not hit its address space limit before hitting the commit limit, depending on the size of physical memory, the size of the paging files and the current commit charge when you run it. If you're running 32-bit Windows and want to see how the system behaves when you hit the commit limit, simply run multiple instances of Testlimit until one hits the commit limit before exhausting its address space.

Note that, by default, the paging file is configured to grow, which means that the commit limit will grow when the commit charge nears it. And even when when the paging file hits its maximum size, Windows is holding back some memory and its internal tuning, as well as that of applications that cache data, might free up more. Testlimit anticipates this and when it reaches the commit limit, it sleeps for a few seconds and then tries to allocate more memory, repeating this indefinitely until you terminate it.

If you run the 64-bit version of Testlimit, it will almost certainly will hit the commit limit before exhausting its address space, unless physical memory and the paging files sum to more than 8TB, which as described previously is the size of the 64-bit application-accessible address space. Here's the partial output of the 64-bit Testlimit  running on my 8GB system (I specified an allocation size of 100MB to make it leak more quickly):

 image

And here's the commit history graph with steps when Testlimit paused to allow the paging file to grow:

image

When system virtual memory runs low, applications may fail and you might get strange error messages when attempting routine operations. In most cases, though, Windows will be able present you the low-memory resolution dialog, like it did for me when I ran this test:

image

After you exit Testlimit, the commit limit will likely drop again when the memory manager truncates the tail of the paging file that it created to accommodate Testlimit's extreme commit requests. Here, Process Explorer shows that the current limit is well below the peak that was achieved when Testlimit was running:

image

Process Committed Memory

Because the commit limit is a global resource whose consumption can lead to poor performance, application failures and even system failure, a natural question is 'how much are processes contributing the commit charge'? To answer that question accurately, you need to understand the different types of virtual memory that an application can allocate.

Not all the virtual memory that a process allocates counts toward the commit limit. As you've seen, reserved virtual memory doesn't. Virtual memory that represents a file on disk, called a file mapping view, also doesn't count toward the limit unless the application asks for copy-on-write semantics, because Windows can discard any data associated with the view from physical memory and then retrieve it from the file. The virtual memory in Testlimit's address space where its executable and system DLL images are mapped therefore don't count toward the commit limit. There are two types of process virtual memory that do count toward the commit limit: private and pagefile-backed.

Private virtual memory is the kind that underlies the garbage collector heap, native heap and language allocators. It's called private because by definition it can't be shared between processes. For that reason, it's easy to attribute to a process and Windows tracks its usage with the Private Bytes performance counter. Process Explorer displays a process private bytes usage in the Private Bytes column, in the Virtual Memory section of the Performance page of the process properties dialog, and displays it in graphical form on the Performance Graph page of the process properties dialog. Here's what Testlimit64 looked like when it hit the commit limit:

image

image

Pagefile-backed virtual memory is harder to attribute, because it can be shared between processes. In fact, there's no process-specific counter you can look at to see how much a process has allocated or is referencing. When you run Testlimit with the -s switch, it allocates pagefile-backed virtual memory until it hits the commit limit, but even after consuming over 29GB of commit, the virtual memory statistics for the process don't provide any indication that it's the one responsible:

image

For that reason, I added the -l switch to Handle a while ago. A process must open a pagefile-backed virtual memory object, called a section, for it to create a mapping of pagefile-backed virtual memory in its address space. While Windows preserves existing virtual memory even if an application closes the handle to the section that it was made from, most applications keep the handle open.  The -l switch prints the size of the allocation for pagefile-backed sections that processes have open. Here's partial output for the handles open by Testlimit after it has run with the -s switch:

image

You can see that Testlimit is allocating pagefile-backed memory in 1MB blocks and if you summed the size of all the sections it had opened, you'd see that it was at least one of the processes contributing large amounts to the commit charge.

How Big Should I Make the Paging File?

Perhaps one of the most commonly asked questions related to virtual memory is, how big should I make the paging file? There’s no end of ridiculous advice out on the web and in the newsstand magazines that cover Windows, and even Microsoft has published misleading recommendations. Almost all the suggestions are based on multiplying RAM size by some factor, with common values being 1.2, 1.5 and 2. Now that you understand the role that the paging file plays in defining a system’s commit limit and how processes contribute to the commit charge, you’re well positioned to see how useless such formulas truly are.

Since the commit limit sets an upper bound on how much private and pagefile-backed virtual memory can be allocated concurrently by running processes, the only way to reasonably size the paging file is to know the maximum total commit charge for the programs you like to have running at the same time. If the commit limit is smaller than that number, your programs won’t be able to allocate the virtual memory they want and will fail to run properly.

So how do you know how much commit charge your workloads require? You might have noticed in the screenshots that Windows tracks that number and Process Explorer shows it: Peak Commit Charge. To optimally size your paging file you should start all the applications you run at the same time, load typical data sets, and then note the commit charge peak (or look at this value after a period of time where you know maximum load was attained). Set the paging file minimum to be that value minus the amount of RAM in your system (if the value is negative, pick a minimum size to permit the kind of crash dump you are configured for). If you want to have some breathing room for potentially large commit demands, set the maximum to double that number.

Some feel having no paging file results in better performance, but in general, having a paging file means Windows can write pages on the modified list (which represent pages that aren’t being accessed actively but have not been saved to disk) out to the paging file, thus making that memory available for more useful purposes (processes or file cache). So while there may be some workloads that perform better with no paging file, in general having one will mean more usable memory being available to the system (never mind that Windows won’t be able to write kernel crash dumps without a paging file sized large enough to hold them).

Paging file configuration is in the System properties, which you can get to by typing “sysdm.cpl” into the Run dialog, clicking on the Advanced tab, clicking on the Performance Options button, clicking on the Advanced tab (this is really advanced), and then clicking on the Change button:

image

You’ll notice that the default configuration is for Windows to automatically manage the page file size. When that option is set on Windows XP and Server 2003,  Windows creates a single paging file that’s minimum size is 1.5 times RAM if RAM is less than 1GB, and RAM if it's greater than 1GB, and that has a maximum size that's three times RAM. On Windows Vista and Server 2008, the minimum is intended to be large enough to hold a kernel-memory crash dump and is RAM plus 300MB or 1GB, whichever is larger. The maximum is either three times the size of RAM or 4GB, whichever is larger. That explains why the peak commit on my 8GB 64-bit system that’s visible in one of the screenshots is 32GB. I guess whoever wrote that code got their guidance from one of those magazines I mentioned!

A couple of final limits related to virtual memory are the maximum size and number of paging files supported by Windows. 32-bit Windows has a maximum paging file size of 16TB (4GB if you for some reason run in non-PAE mode) and 64-bit Windows can having paging files that are up to 16TB in size on x64 and 32TB on IA64. Windows 8 ARM’s maximum paging file size is is 4GB. For all versions, Windows supports up to 16 paging files, where each must be on a separate volume.

Version

Limit on x86 w/o PAE

Limit on x86 w/PAE

Limit on ARM

Limit on x64

Limit on IA64

Windows 7

4 GB

16 TB

16 TB

 

Windows 8

 

16 TB

4 GB

16 TB

 

Windows Server 2008 R2

   

16 TB

32 TB

Windows Server 2012

     

16 TB

 

Comments

  • Anonymous
    January 01, 2003
    The comment has been removed

  • Anonymous
    January 01, 2003
    Love your blog! The technical detial is mind blowing. I am not sure if this is the place to ask a question. I am running Vista Ultimate 64-bit edition on a Intel Core 2 Duo 2.53 Ghz with 4GB RAM and a Nvidia Gefore 9600GT graphics card. How can I squeeze maximum performance out of Vista Ultimate on my hardware ie. speeding up boot time, response time of system services?

  • Anonymous
    January 01, 2003
    "I do think that setting the pagefile to a fixed size is better because of fragmentation (and therefor performance) reasons. " Just defrag the pagefile and then you don't have to worry about it...

  • Anonymous
    January 01, 2003
    Hi, According to this post, when running a large address aware 32-bit application in a 64-bit windows 7 the application could use the full 32-bit address space (4GB). This makes sense to me, however when running Visual Studio 2010 the limit is reached around 2GB. Why is this happening? I checked with dumpbin /header and the devenv.exe it can handle large addresses (when run "editbin /largeaddressaware devenv.exe", don't know how it was before). I would like to understand why. Thanks, Nuno Pereira

  • Anonymous
    January 01, 2003
    @DW: You could push it to 3300 with the /UserVA=3300 boot.ini switch (or bcdedit equivalent). The extra 300Mb isn't much more though (compared to /3Gb), and you'll put a lot of pressure of NPP and PP to fit in the remaining 700Mb.  Note, if you use an x64 OS, you'll still only get 4Gb (with the x86 program).  You need to get an x64 app on an x64 OS to really benefit from extra (>4Gb) memory.

  • Anonymous
    January 01, 2003
    I don't understand why people say that, in conditions where analysis shows you don't need a pagefile (you fully operate in RAM with room to spare) you should still create a pagefile to free up RAM for other purposes ("making that memory available for more useful purposes "). If all of my purposes fit in RAM, what exactly am I freeing memory for?

  • Anonymous
    January 01, 2003
    Large address awareness is specified with the IMAGE_FILE_LARGE_ADDRESS_AWARE flag in the IMAGE_FILE_HEADER structure of the PE header: http://msdn.microsoft.com/en-us/library/ms680313.aspx

  • Anonymous
    January 01, 2003
    The comment has been removed

  • Anonymous
    January 01, 2003
    @Brian: The limit is per process and not per computer. Windows itself (the Kernel) seems to use AWE.

  • Anonymous
    November 18, 2008
    Brilliant post Mark. Thanks for writing this. As an Active Directory guy I wanted to remind readers to beware of configuring DCs without any page file, even on DCs with lots of RAM and where the commit charge peak is low relative to the commit limit. The database engine depends on the page file per KB 889654. Cheers

  • Anonymous
    November 18, 2008
    The comment has been removed

  • Anonymous
    November 19, 2008
    I was involved in choosing the default min/max sizes for system managed pagefiles in Vista, and I'm pretty sure those numbers were not just copied from some magazine :) The 1 GB minimum was chosen based on the actual commit charge observed on small machines (512 MB of RAM). The 3*RAM maximum might seem excessive on machines with lots of RAM, but remember that pagefile will only grow this large if there is actual demand. Also, running out of commit (for example, because of a leak in some app) can bring the entire system to a halt, and a higher maximum size can make the difference between a system that does not respond and has to be rebooted and a system that can be recovered by restarting a process. I will admit that scaling the maximum size linearly with the size of RAM is somewhat arbitrary. Perhaps it should have been a fixed constant instead.

  • Anonymous
    November 19, 2008
    Great post (as always)! I love the amount of detail in your posts. Everyone looks at task manager and tries to draw some conclusions, but thanks to you I am starting to really understand what the numbers mean. Hugo

  • Anonymous
    November 19, 2008
    A few more points:

  1. Reserved memory does contribute to commit charge, because the memory manager charges commit for pagetable space necessary to map the entire reserved range. On 64 bit this can be a significant number (reserving 1 TB of memory will consume approximately 2 GB of commit).
  2. The Private Bytes counter is named a bit misleadingly, because it includes more than just committed MEM_PRIVATE regions. It's better to think about it as the process commit charge. Besides private committed pages, it includes things like copy-on-write views and pagetable pages.
  3. Configuring a system with lots of RAM to run without pagefile may have either negative or positive perf impact depending on what the system is doing. The general recommendation in this case is to create a reasonably sized pagefile (for example, 4 GB) and increase it if the Paging file% Usage counter gets close to 100%. Note that this counter is completely different from what task manager calls "pagefile usage" (which is actually the system commit charge). Paging file% Usage of 100% would mean that some unused pagefile-backed pages are sitting on the modified page list, unnecessarily taking up RAM. If pagefile was larger, those pages could have been written to disk, resulting in more RAM available for other purposes.
  • Anonymous
    November 19, 2008
    I think I never read a more fundamental article about managing the Windows Virtual Memory. Thank you very much for this, I think many people will now be able to reasonably set the size of the Virtual Memory. "I guess whoever wrote that code got their guidance from one of those magazines I mentioned!" made me giggle! :-)

  • Anonymous
    November 19, 2008
    It's worth noting that previous Windows versions (as late as Windows 2000) permitted the creation of multiple page files on a single volume with a registry edit. This was primarily used when the formal recommendation from Microsoft was for 1.5x RAM (Exchange Server anyone?) and the system had more than 4GB of RAM. Using the "one page per volume" strategy required 2 or more drive letters. Instead, each pagefile could be 4GB and placed in a separate directory. I think it was "HKLMSYSTEMCurrentControlSetControlSession ManagerMemory ManagementPagingfiles" but my memory is not perfect.

  • Anonymous
    November 19, 2008
    nice one! but what do i do with the pagefile on a 64 bit server 2003 system with 32gb ram, with a memory-intensive application? ... let's call the apllication ... exchange 2k7 :-)

  • Anonymous
    November 19, 2008
    I just bought a Gigabyte i-RAM RAM DISK to put my "virtual memory" on a RAM DISK. I didn't realize accessing virtual memory is application specific, so this is great information! Thank you.

  • Anonymous
    November 19, 2008
    The comment has been removed

  • Anonymous
    November 19, 2008
    o.s.: no, its a bit flag in DllCharacteristics IIRC

  • Anonymous
    November 19, 2008
    Another fantastic post!! The detailed level of your articles is completely awesome!

  • Anonymous
    November 19, 2008
    Thanks Mark for the reply. I was so busy researching asf's comment that I hadn't checked back on the latest comments. Thanks everyone.

  • Anonymous
    November 19, 2008
    The comment has been removed

  • Anonymous
    November 19, 2008
    Is this a fair summary of why the 3GB is an option that is off by default: Either lots of 2GB processes at the same time with a 2GB system virutual memory to manage all those resources, or a limited number of 3GB processes with a smaller system virtual memory of 1GB to manage them? And what is wrong with just letting Windows manage the page file? Won't it choose a reasonable size and grow it if necessary?  I always just assumed it would never shrink, but Mark seemed to suggest the page file will be truncated when the commit charge drops. Is setting a fixed size to avoid the stall as the swap file is grown or shrunk in size, or to avoid the on-screen message that, 'Windows will increase the size of the virtual memory file' - message that cannot be clicked if running on an unattended server? On a workstation, is there really any point?  Will people notice a difference?  

  • Anonymous
    November 19, 2008
    Great article, but I there's one important thing that should be mentioned: address space fragmentation. So I recommend reading also http://forall.ru-board.com/egor23/online/FAQ/Virtual_Memory/Limits_Virtual_Memory.html

  • Anonymous
    November 19, 2008
    three things

  1. In the last paragraph, the maximum page file size on 32 Bit windows and 64 Bit windows seem to be the same, at 16 TB. Is this really right?
  2. How is memory managed for DirectX (aka Games!). Obviously they still go through Kernel and such, but I know games often allocate memory to try to force only physical memory usage. Will having paging file help at all? How does OS behave?
  3. On Vista 32-bit, is 3GB option enabled or disabled? And if disabled, how do I get it going on my 4gb PC?
  • Anonymous
    November 19, 2008
    Hello and thank you for this excellent post. I have a question and comment about virtualized server environments To avoid swapping within a virtual W2K3 VM, I configure them with a chockfull (1,2,4GB) of RAM and let the hypervisor manage the pseudo physical allocation. With your post, I am thinking I might still need to provide some paging within the VM. Any comments about either statements?

  • Anonymous
    November 20, 2008
    Thank you for this excellent post; very informative. Are you going to go on to discuss other topics (eg. the paged and nonpaged pools of kernel memory and how to figure out what's going on with them)?  I ask because my PC currently seems to have a nonpaged pool leak (which I've traced to pool "TdxA", but I'm not sure where to go from there).  My computer (Vista32) gets dangerously flaky once the non-paged pool gets to around 1GB.  (It's also not happy when the total handle count gets above 45,000 or so, but that's less serious.)

  • Anonymous
    November 20, 2008
    Great article! Maybe a stupid question but what is the disadvantage of setting a too big paging file?

  • Anonymous
    November 20, 2008
    Pavel, you said that:

  1. Configuring a system with lots of RAM to run without pagefile may have either negative or positive perf impact depending on what the system is doing. Could you please give me some examples of negative performance impact, if I have 4GB XP32 w/o pagefile? And similar question: my colleagues was once set and experiment with 2GB pagefile on the 4GB RAMDrive on the 8GB XP64. I think that this doesn't make sense at all. What do you think? Sorry for probably bad English =)
  • Anonymous
    November 20, 2008
    I do think that setting the pagefile to a fixed size is better because of fragmentation (and therefor performance) reasons.

  • Anonymous
    November 20, 2008
    Excellent post, can't wait for the next edition of Windows Internals to hit the shelves.

  • Anonymous
    November 20, 2008
    Great article! May I suggest a topic for a future article? I would love to see discussion about Windows memory management policies. E.g., when pages get swapped out and how that is decided; if and how those policies are customizable; etc. I often see situations where recently-inactive pages are swapped out too soon, when there is plenty of available physical memory. This is especially problematic with Java (or any other garbage-collected environment for that matter) applications, where most of the pages have to be swapped in for each garbage collection.

  • Anonymous
    November 21, 2008
    Thank you for the great article. Just a small tipo, Testlimit is also marked large-address aware, so if you run it with the –m switch... should be -r switch (or the screenshot command should have been -m :)

  • Anonymous
    November 21, 2008
    I am running Vista with 4GB of physical memory. I also have a USB drive with Readyboost enabled. Is Mark saying it is foolish to allow Windows to manage my virtual memory? Am I supposed to manually tweak my pagefile size for maximum performance?

  • Anonymous
    November 21, 2008
    Is it [still] true that, when the low-memory resolution dialog appears, some random thread of some random process has already been commandeered for that purpose and therefore the system must axiomatically be regarded as unstable?

  • Anonymous
    November 22, 2008
    The comment has been removed

  • Anonymous
    November 24, 2008
    Brilliant read as always Mark. I adore the work you do, the blogs you write, the apps create and Events you speak at. I am waiting in anticipation for the 5th edition of windows internals to drop through my door. Sadly its 2 months away yet :'( Cheers!

  • Anonymous
    November 24, 2008
    The comment has been removed

  • Anonymous
    November 24, 2008
    Even though my earlier comment never got posted, here's an update for whoever is reading/moderating... I had mentioned that 32-bit testlimit on my 4GB XP64 system was reporting something just a bit shy of 2GB when it should've been reporting just shy of 4GB. I finally discovered that I was using an ancient version of testlimit that was not marked large-address aware. I downloaded the latest version of testlimit (v5) and it is now reporting 4GB as expected. Alan

  • Anonymous
    November 24, 2008
    The comment has been removed

  • Anonymous
    November 24, 2008
    By the way, there are actually 2 separate reasons why pagefiles are necessary. The first reason is to allow dirty pages that are never (or very rarely) referenced to be moved to disk, freeing up more RAM for other purposes. The other reason is to enable better use of virtual memory, given that physical memory is allocated on demand. Remember that when a process calls VirtualAlloc(MEM_COMMIT) there are no physical pages allocated at this time. Physical pages are only allocated when the app accesses virtual pages for the first time. This is good because it makes committing pages a relatively cheap operation, so apps can commit memory in bigger chunks, without having to worry about each page they may or may not use. Now, even though committing memory does not allocate physical pages, it still guarantees to the application that reading from/writing to the committed pages will never fail (or deadlock). It might be slow if other physical pages have to be moved to disk in order to make room, but it will eventually succeed. In order to make that guarantee the memory manager has to assume that every committed page in the system might eventually be written to. And that in turn means that there has to be enough space in the physical memory and all the pagefiles combined to hold all the resulting data. In other words, the total commit charge has to be less than the system commit limit. Once the limit is reached, the memory manager will refuse to commit any more memory, even if there is still plenty of unused (free+zeroed) physical pages, or plenty of unused space in the pagefile. In a sense, pagefiles are like stormwater ponds. Most of the time they are (almost) empty, but they have to be large enough in case a big storm happens.

  • Anonymous
    November 25, 2008
    Good article - thanks. And now a carping criticism for which you personally are not responsible: why is it that Task Manager seems to want to mislabel important system metrics? Like, for example in XP, displaying the commit charge as 'PF Usage' (was 'Mem' in Windows 2000). I suppose whoever's in charge of these things has decided that the average user can't understand 'commit charge', but is lying to them going to help?  I've lost count of the number of times I've had to point out that just because Task Manager says you're using 1GB of pagefile, it doesn't mean you're using 1GB of pagefile (on your system that has no pagefiles configured, even). dave

  • Anonymous
    November 28, 2008
    Mark - could you talk about observing the size of applications using AWE?

  • Anonymous
    November 30, 2008
    In the last paragraph, the phrase "32-bit Windows has a maximum paging file size of 16TB" surely should have been 32GB, not 32TB, right?

  • Anonymous
    December 01, 2008
    The comment has been removed

  • Anonymous
    December 01, 2008
    Everyone downloaded the 5.0 Version of Testlimit? It seems to have a bug.... I am running on a 32Bit WinXP SP3 Machine and when I use Testlimit with the -s or-m switch and so on it doesnt take the MB Parameter and allocates the maximum instantly.... Solutions?

  • Anonymous
    December 01, 2008
    Regarding the comment/question above 32-bit Windows, running in PAE mode, does has a maximum paging file size of 16TB. (or in practice the size of the underlying disk) Most 32bit systems run in PAE mode by default these days. Without PAE mode, the limit, for any single pagefile, is 4GB

  • Anonymous
    December 04, 2008
    The comment has been removed

  • Anonymous
    December 04, 2008
    I seem to recall the reason for the 3x paging file recommendation was made by Intel long back in the days when the 80386 was first introduced.

  • Anonymous
    December 05, 2008
    Typo I believe: The figure isn’t drawn to scale, because even 8TB (should be 8GB instead of TB) , much less 128GB, would be a small sliver. Suffice it to say that like our universe, there’s a lot of emptiness in the address space of a 64-bit process. Great article!

  • Anonymous
    December 05, 2008
    The comment has been removed

  • Anonymous
    December 05, 2008
    Intel's 32 bit processors since the 80386 all address 48 bits of logical memory (2^48) via a 16 bit segment register and 32bit offset pointer. IMHO, the modern generation of operating systems does not exploit this because 32 bits of addressable memory is "more than anyone would ever need" and dealing with "NEAR" and "FAR" pointers was a major fiasco in the early days of Windows coding. Thought I would point it out since you failed to mention this.

  • Anonymous
    December 08, 2008
    The blub "virtual-memory-related limits in Windows, that includes information on how to track down virtual memory hogs and how to size the paging file." is not fully covered by article. I still can't track down memory hogs as claimed. I installed Virtual Server and created a VM with 256MB RAM. My system now seems to use an extra 1GB RAM (eg. 1.4GB after vs 400MB before) that is not hidden/un-accounted for. I would have thought it would be closer to 256MB + VM server/helper. The two articles still don't help to calculate the memory used by numerous OS structures, where the disk cache fits in or the problem with only 1GB for OS. 32bit OS system calls use 32bit pointers and the memory windowing of PAE I think works for apps not OS or drivers. It's very messy to copy data between windows of ?GB because they can't be addressed at the same time or shared between programs (eg. OS and app). Other system resources (eg. handles, desktop heap) are often exhausted by loading multiple small programs (eg. IE windows) before 2GB VM is used. Some people are confused by "Available Physical memory" which is also used by the "system cache" and is not the total addressable RAM. You can have physical memory available but cannot allocate additional memory for OS/app because it's in the other half (eg. 1GB OS, 1GB apps split of 2GB).

  • Anonymous
    December 08, 2008
    The section on how to size the pagefile is the most concise explanation I've seen on the subject and easily worth the price of admission. I was charged with figuring this out awhile ago for a system that consisted exclusively of boot-from-SAN iSCSI storage with dedicated pagefile volumes (to avoid SAN replication) so we didn't want to waste expensive SAN storage space on large pagefile volumes. Most web articles on the subject are years behind the times, when everything was 32-bit and 1GB of RAM was a luxury and 4GB was unheard of. After much reading and observation, I basically came to the same conclusion as Mark (Peak Commit Charge + Fudge Room) with a 1GB minimum, since I remember reading that the OS generally wants at least SOME pagefile space for basic housekeeping. Can anyone explain what that housekeeping is? The hardest part of all this research was convincing IT monkeys, who apparently read the same magazines as the MS engineers and are firmly convinced that pagefiles must always be 1X-3X RAM, that it doesn't work that way when you have an x64 SQL Server with 32-64GB of physical RAM! Thanks for a great read Mark. I'm looking forward to Windows Internals 5th Edition.

  • Anonymous
    December 10, 2008
    @Kerry C, I don't think he even implied that LSASS was AD specific.  It's pretty clear that it's not to even a novice user.  That's the same with Esentutl.   Giving an instance of how these things matter for the given context is right way to write a paper.  There would be no reason for Mark to talk about how these things are not useful to the discussion to make his point. I thought this was extremely informative.  Just my 2 cents.

  • Anonymous
    December 25, 2008
    Thanks Mark for a informative article in Windows Virtual memory. Would u please provide some information about the virtual memory limits of Windows 7

  • Anonymous
    December 27, 2008
    The comment has been removed

  • Anonymous
    December 29, 2008
    This really helps with setting the pagefile size on netbooks that use Solid State Drives with limited space.  Typically we can't afford to waste space on an overly large page file created on a system with 2GB RAM and an 8 or 16GB drive.

  • Anonymous
    January 05, 2009
    I am so glad this article is out, along with the comments.  It clarifies much while illustrating how complex this subject is.  I think this needs to be republished every year to counter the utter drivel on the web and magazines. For my part, I have been charged with configuring and supporting servers of various sizes, needs, and flavors the better part of 30 years (remember the pdp-11/70?).  I have simplified support 1000% and DR with this rule:  No paging file unless proven first that it is needed.  Paging to a disk file is almost always transient data, there is no need for OSes these days to page programs/librarys/data that it has read from disk already.  Like getting an error in your program, just one is already too many, having your application write to a page file just once is very expensive, so just dont do it. To those many, MANY thousands of so called professionals who believe a server reboot should be avoided at all costs, sing to the window patching group.  A server that can automatically reboot in 20 seconds is almost always more cost effective than 1 or 3 technicians standing around a console for a couple of hours trying to get a handle on a errant application (just how do you quickly prove killing a process does not have unintended consequences).   I had one vendor scream at me they had to have 6x the size of physical RAM.  I asked them to write to me how long would it take for them to write and then read 48GB of paging file, and then explain how that would affect their guarantee of 500 transactions per second.  I set no paging file and we did 3000 transactions per second for life of the application (78 months). I have played with both 32-bit (2GBRAM) and 64-bit (4GB) Vista for more than a year, they have minimum page file set -- mostly to avoid the nag pop up.  I have yet to find anyhing that fails or slows when it does not exist.

  • Anonymous
    January 09, 2009
    Great read Mark.  Thank you bunches.

  • Anonymous
    January 10, 2009
    Thanks Mark for a informative article in Windows Virtual memory. Would u please provide some information about the virtual memory limits of Windows 7.(This is the second time i am posting this.pls comment on it )

  • Anonymous
    January 10, 2009
    @ John Cairns, Windows would gain nothing by using non-flat memory model (a model with 48-bit segment:offset addresses), because segment:offset address is always translated to 32-bit virtual address - if it's larger than 4 GB, MMU truncates it to 32 bits, so you are still limited to 32-bit address space.

  • Anonymous
    January 12, 2009
    <<<I've always suspected that swapping out application memory to make space for a bigger file cache is not such a good idea in many scenarios [...] maybe I'm just deluding myself in thinking that there must be a better way.>>> I work with digital video instead of videogames, but the issues are mostly the same you describe. And there used to be a better way, aka Win9X, where you were able to configure a maximum disk cache size and prevent ahead-of-time swap out. NT4 seemed to have similar settings (Mark even created a cache config utility for NT4). The current policy (swap out early and cache all you can) works well enough when you randomly access many small files (servers, batches, office workstations) or the application used to access very large files manages its own cache (databases). But when you sequentially scan a file that's several GB in size, which takes a while, the system will end up swapping out practically every other process, including most of explorer.exe, and fill up the physical memory with useless disk cache (the same sector is never access twice). After that, using your system requires great patience. Even simply watching a DVD or looking at your holiday pictures makes it hard to multitask, and those are not niche scenarios. On Win9X, enabling the conservative swap usage and limiting the cache to a reasonable size for most office-like activities made all of the above disappear and the system was always responsive (even the MSDN Library viewer and VisualStudio were much faster than on Win2K/XP/2K3). Unfortunately, in its infinite wisdom (aka the "one size fits all" policy), MS dropped those settings in NT5/6, which is practically the only reason why I kept a Win98SE system as my main personal and dev machine until 2004.

  • Anonymous
    January 14, 2009
    Great thanks for this great guide. It seems though that I've been doing something wrong. I've got xp sp3 with 2 gb of ram. So, following what mark suggests, I've opened all the programs that I use, then checked the Peak Commit Charge value, and it was about 1,8 gb. So, I set Virtual memory size to min:200-max:1000. But then, after some time, after having LESS programs opened now, I always got a popup saying that system run out of memory and that performance may degrade... So I tried to increase it's max limit by steps of 100, but even when I got to eg, 1400 (with eak commit charge always equal or less than 2 gb), I still got that warning about the memory. So, I had to set virtual memory to Auto, to make these popups stop. Any syggestions?

  • Anonymous
    January 28, 2009
    Hi Mark, Do the same guidelines apply for a Win2K8 system running a Hyper-V role?  Likewise if it's a server-core install? I am wondering whether the pagefile on a Hyper-V host would have any value (other than the standard paging maintenance purposes you mention) Darryl

  • Anonymous
    January 30, 2009
    The comment has been removed

  • Anonymous
    February 03, 2009
    The comment has been removed

  • Anonymous
    February 03, 2009
    I noticed the same problem on not being able to open more IE windows after a certain numbers of windows open or after a certain period of time on my newer pcs. I had 2 Dells running intel C2D/2GB that have this problem and i thought it was the pc itself. And then i built another 2 systems using AMD 64 X2 with Abit MB and 4GB ram and they does the same thing. But, i have 2 other older pcs running AMD Athlon XP with 1GB on one and 768mb on another that does not do this. These systems are all running XP Pro SP2(updated to SP3 lately). Still trying to figure out why it does that.

  • Anonymous
    February 08, 2009
    So I have just upgraded my laptop from 2GB RAM to 4GB on a 32-bit Vista installation.  I may move to 64-bit at some point, possibly as part of an upgrade to windows 7, but my maximum memory use is closer to 3GB than 3 1/2 GB, so there's just no pressing need at the moment. Given that I now have more memory than my computer can possibly use (after subtracting various graphics, driver, and legacy sections) given a 32-bit address space, what cost is there to me of disabling the page file entirely?  Swapping in this case does not increase the total amount of memory I can use, and should not make my system more stable.   As far as I can see, it should only serve to make my system slower, by aggressively swapping out stuff I still want in memory.

  • Anonymous
    February 10, 2009
    Hi MR, thanks for the wonderful post as per usual.  I have a production SQL Dell 1950 server with 16 GB RAM and I am upgrading it to a capacity of 32 GB RAM.  It currently has the following: Peak Bytes: 33,325 Mb Commit Limit: 37,062 Mb Commit Peak:  34,269 Mb Paging Files as follows: C: Min: 2,048 Mb C: Max: 4,096 Mb D: Min: 6,144 Mb D: Max: 10,240 Mb P: Min: 6,144 Mb (Dell MD 3000 SAN) P: Max: 10,240 Mb (Dell MD 3000 SAN) Paging File Current Allocation: 14,336 I would like to know how I can tweak my paging files to make sure I am using the RAM optimally once I install the additional 16 Gb Regards in advance Virtigo

  • Anonymous
    February 17, 2009
    Just curious, I have also noticed this Limit with I.E. Dont think it is IE, just an interface that it uses. However, I also do not have this issue on an older machine. Is it possible that this is related to 64bit proccessors? Even if the OS is 32Bit most modern Proccessors are 64 bit capable?? Could there be something screwy happening here? Just as an aside, get to your limit with I.E, now close the last window and open Calculator, you can open this 3 or 4 times. I have looked at handles, threads, proccess, memory, nothing is coming close to its limit (Okay the physical memory was 1,7-1,74 GB but that is for me to arbitrary. If it is always 1,73 then its a point. but random values say somehting else to me.

  • Anonymous
    February 17, 2009
    okay,  maybe a little misleading in the previous post. It looks like it is reaching the maximum amount of User Handles/Objects and this is causing the strange behaviour. Calculator requires a lot less User Handles than IE :D I am interested though why I get more user handles in a machine with more RAM? I thought this was a set limit? can there be something with the way Windows is handling user handles when mor RAM is available? (Paging or not reading or whatever?)

  • Anonymous
    February 18, 2009
    The comment has been removed

  • Anonymous
    February 24, 2009
    I have a Windows 2003 R2 Enterprise server with 32 GB of RAM currently running a 32 GB pagefile.  The Peak Commit Charge is around 5 GB.  What size should I make the pagefile?

  • Anonymous
    March 19, 2009
    MarkR: Regarding setting the pagefile size, I must disagree with the advice in the article. You suggest subtracting RAM size from the peak observed commit charge and setting the pagefile size to the difference. Result: your pagefile plus RAM have enough space to accommodate your peak commit charge. However this does not leave any room in RAM for code! Or any other mapped files. Or for the operating system's varous nonpageable allocations. Remember, "commit charge" does not include these. My recommendation is to set up your maximum workload, then use the very convenient performance monitor counter, Page file / %usage peak. Your pagefile should be large enough to keep this under 25%, 50% at worst.  Reason - lots of breathing room helps avoids internal fragmentation of the pagefile. You really don't want to run the pagefile close to 100% full, especially with Vista and its much larger pagefile writes.

  • Anonymous
    April 30, 2009
    We recently got new Dell Workstation pcs, running 32 bit XP-sp3, with 4 GB ram (dual quad processors).  Due to frequent memory error messages, we had virtual memory set to 12280-12280.  This problem occurred using MS Word, MS Outlook, Adobe Acrobat Professional (reading 40 mb pdf), ArcMap and Microstation. No memory problems since.  Users can't run defrag or make system changes, so this was the administrator solution. Note: I was previously using a Dell Optiplex 620, same operating system, with 4 GB ram and never had virtual memory error messages.

  • Anonymous
    May 15, 2009
    As a relative newcomer to computers I am curious, Given that 32bit windows XP/Vista/Windows 7 cannot address much more than 3GB RAM, and that hardware considerations may reduce this, If a machine has 4GB memory installed (e.g. 2x2GB) Is it possible for the remaining memory (if any) up to 1GB to be used as a RAMDRIVE. External Constraint prevent me from using a 64bit OS for now, and I feel it would be beneficial to make use of any unused portion of memory. It can be used to speed up systems perhaps by caching commonly used files following system startup or used for Virtual Machines as a container for Virtual Page Files rather than storing these on the Disk. Thanks for any constructive help and guidance.

  • Anonymous
    May 16, 2009
    The comment has been removed

  • Anonymous
    May 21, 2009
    I've seen a couple of things here on SQL, but I am still questioning the recommended pagefile size for a MS SQL server (SQL 2005, 64-bit) with 32 GB of physical RAM.  1.5 x says it should be 48 GB, which seems huge to me.  I've looked at the perfmon stats and the pagefile useage is usually less than 10% of my current 4 GB pagefile, so why would I need a bigger pagefile than that?

  • Anonymous
    May 21, 2009
    Hello, The way I looking at is that long time ago when x64 did not exist was needed apply the 1,5 figure. Nowadays this is no longer needed. With such as amount of memory and having x64, this is the most important, 4Gb of page file is more than enough. I strongly recommend you take a look at: http://support.microsoft.com/kb/889654 Hope this clears up your question. Cheers.

  • Anonymous
    May 24, 2009
    Thankyou SuperGumby, You are right I am somewhat confused by the 2/2 1/3 rules but this is in itself complicated by virtue of the fact that many (but not of course all) so called "Authorities" including Magazines and related Authors, Manufacturers of Computers and Computer Accessories in particular Laptop's and smaller computers to name a few who state that 32bit Windows on most if not all Computers cannot address much more than 3GB of physical memory. There may be genuine reasons such as chipset limitations or limitations imposed by drivers, the kernel in relation to hardware, where certain hardware may not access or address all memory above around 3GB. It would be helpful if the article could be updated to give examples where there might be hardware, kernel, driver or other limitations rather than just a general Operating Systems limitation. In my case I intend to install and use more than 4GB of RAM on hardware which supports it, as I would be dual-booting between 32bit XP and 64bit Linux and running Virtual Machines from either. The only reason for using XP is that certain software particularly that which relates to hardware such as hardware support tools from manufacturers, and certain applications for playback of copywrited materials such as some DVD's and BlueRay disks cannot be run from Linux or within a Virtual Machine (As far as I am aware) As I can apparently address the full 4GB from within 32bit XP then I will increase the memory allocation to the Virtual Machine and reduce or remove dependancy on Page Files/Swap Space for Virtual Machines.

  • Anonymous
    August 07, 2009
    Hey, just wanted to thank you for an excellent guide!  You really cleared up some of the mystery of how Windows handles its virtual memory addressing. I had another question that I couldn't quite figure out.  In 32-bit Windows, is there a maximum of 2GB (or higher with 4GT) of user address space PER process, or TOTAL for all processes?  More simply, could I run two memory-hungry applications and let them each allocate 2GB, provided I have sufficient physical and pagefile memory available? The reason I ask is that it would help me pick the ideal pagefile size and the 4GT setting.  If the user address space is a total for ALL applications, that would suggest 4GT would assist with any amount of physical memory and that there's no point to having more than 4GB of physical + pagefile memory.  Conversely, if EACH process can have a full-sized user address space of its own, 4GT would be pointless on a system with 2GB or less of physical memory, and pagefiles could conceivably be well-utilized at any size (depending on how many processes you are running). I'm guessing based on your article that 32-bit Windows memory management is able to keep more than 4GB of total virtual address space, separated into chunks that each fit into a 32-bit space.  But I'd like a definitive answer from someone more knowledgeable in this area.

  • Anonymous
    August 09, 2009
    > In 32-bit Windows, is there a maximum of 2GB > (or higher with 4GT) of user address space PER > process, or TOTAL for all processes?   The former. Hence "user address space" is also called "per-process" address space. You get 2GB of it per process. Or 3GB with the /3GB option. > More simply, could I run two memory-hungry > applications and let them each allocate 2GB, > provided I have sufficient physical and > pagefile memory available? Yep. In fact you would not need physical + pagefile space for 2GB x nProcesses if they're doing a lot of file mapping instead of VirtualAlloc and similar - see below. > The reason I ask is that it would help me pick > the ideal pagefile size and the 4GT setting.   The ideal thing is to stop worrying about "ideal" pagefile size - just make it big enough to keep actual pagefile usage fairly low. I like to see it below 50% absolute worst case, ideally below 25%. With modern hard drive prices this should not be difficult. > Conversely, if EACH process can have a full- > sized user address space of its own, 4GT would > be pointless on a system with 2GB or less of > physical memory, No, not at all. Not everything has to be paged in (that is, in physical memory) just because it's defined. Remember that the whole point of paging and virtual memory systems (well, one of the main points) is something akin to a 90/10 rule: most programs spend 90% of their time referencing 10% of the address space they have defined. The rest can be kept out on disk. Or 80/20, or whatever - but for almost all programs the ratio is not much lower than that. For example, if you never use the "spell check" function in Word, that stuff never gets paged in. But if it was linked with the app at link time, it occupies virtual address space whether it's used or not. So a process might take advantage of the (strangely named) "4GT" option and use up to 3GB of v.a.s., but to run efficiently might need only 300 MB of RAM ("working set" in the Vista Task Manager). You might have a several processes like that and they would likely be just fine in 2GB RAM. Another point re. pagefile size is that code (as opposed to process-private writeable data) normally never gets paged out to the paging file - but of course when it's being executed it does have to live in RAM and it does occupy process virtual addrsss space. The total virtual address space defined by a process includes both "pagefile-backed regions" (also called "process-private", "private bytes", and "committed" memory)  and "memory mapped regions". The latter is how program code is accessed, and it can also be used for data files. Thus the total v.a.s. possible on a system is NOT limited to RAM + pagefile size; it may be much larger. The "extra" is in all the mapped files, which include every exe and dll currently in use. > I'm guessing based on your article that 32-bit > Windows memory management is able to keep more > than 4GB of total virtual address space, > separated into chunks that each fit into a 32- > bit space.  But I'd like a definitive answer > from someone more knowledgeable in this area. Yes. You can demonstrate this easily with the Performance Monitor tool. Click the big Plus sign (Add counter to chart), select the Process class of objects, select the "virtual bytes" counter (this includes both pagefile-backed and mapped address regions), and select the "Total" instance. On any reasonably busy system you will likely get a number quite a bit larger than 4GB. The URL I've given here is not my URL, but is a link to a forum post at arstechnica.com that illustrates how the per-process address spaces look in a memory map. Also read the next post by the same author (two posts down).

  • Anonymous
    August 11, 2009
    Thanks for the great post Jamie! You bring up an excellent point about applications allocating more memory than they will use frequently, so I think I will try setting the 4GT on my desktop PC to 2.5/1.5, even though it has only 2GB RAM. I've given both of my machines fixed 4095MB contiguous pagefiles, so regardless of how much or little paging is necessary at any time, there should be no fragmentation caused by the pagefile changing sizes. Now, one last question... is Windows smart enough to avoid paging out when there's plenty of physical memory to go around?  In other words, is there any disadvantage to having a large pagefile?

  • Anonymous
    August 14, 2009
    > is Windows smart enough to avoid paging out > when there's plenty of physical memory to go > around?   In general yes. If free RAM is plentiful processes will be allowed to grow their working set (roughly "what they have paged in") above the usual limits. If RAM later becomes scarce, one of the first reclamation mechanisms is that these "extended" processes are shrunk back down. However that little experiment with the virtual bytes counter should show you that you can't expect to keep everything in RAM all the time, or even everything that's useful in RAM. The page I/O rates, also visible in Performance Monitor, will tell you how much paging is happening, but it's very difficult to tell how much paging is due to low memory conditions and how much is due to the fact that, in a virtual memory OS, paging happens. All code and pre-initialized data is brought in via paging, for example. So are the contents of all data files that are opened without bypassing the file cache. Even the page write rate is not directly useful, because you don't know how many of the pages written are going to be needed again soon, or ever. A "page re-read rate" would be a really useful counter to have: How many pages are being faulted in from disk that were previously pushed out of RAM? Alas this counter does not exist and I know of no way to calculate or infer it from existing data. One other hint: Your paging I/O rates do not reflect only the pagefile, because all mapped files (exe's, dll's, data files accessed via the file cache as well as through direct file mapping) are read and, if appropriate, written by the pager. If you want to know the page I/O rates to just the pagefile, the only way I know of is to put the pagefile by itself on a partition and then use the partition (logical disk) I/O counters. And this is about the only good reason for putting the pagefile in a partition of its own on a multi-partition disk. > In other words, is there any disadvantage to > having a large pagefile? This is really a larger question, but no, not to my knowledge. In particular, increasing the size of the pagefile will not "attract" more page-out activity than would otherwise occur, all things being equal... and it will help keep the internal fragmentation of the pagefile low.

  • Anonymous
    December 10, 2009
    The comment has been removed

  • Anonymous
    December 16, 2009
    > but what do i do with the pagefile on a 64 >bit server 2003 system with 32gb ram, with a memory-intensive application? ... let's call >the apllication ... exchange 2k7 :-) >Wednesday, November 19, 2008 7:57 AM by robad Was this ever answered. I do not see the answer in the thread. My scenario would need this answered as well. What we are trying to do is get a full Ctrl-ScrollLock Memory dump due to some system hangups we have been experiencing. With 32gb of RAM on the system, for a full dump to be possible, besides setting CrashDumpEnabled in HKEY_LOCAL_MACHINESYSTEMCurrentControlSetControlCrashControl and CrashOnCtrlScroll HKEY_LOCAL_MACHINESYSTEMCurrentControlSetServicesKbdhidparameters in the registry, to allow for a full dump, we would also need a page file equal to RAM +100mb per Microsoft's own performance team. Is this accurate? Are there any pitfals to setting a page file to this size?

  • Anonymous
    January 19, 2010
    One Question. I have 4GB installed, bios detects them, windows xp 32bit still has the 2gb user space limitation. Ok. I know about virtual address-space, I am a c++ progammer. Assuming I have 4 apps using 1gb of memory each (lets assume a huge working set of unpaged memory), shouldnt the computer be able to profit from 4gb physical ram vs 2gb physical ram? thanks for answering

  • Anonymous
    March 03, 2010
    Replying to "Another Voice". We need to keep things straight between virtual address space, physcical memory limit, process size limit, etc. Your computer is fully benefited from the 4G of physical mem (2G is allocated to apps, and 2 G to the kernel).  Although at the default, 2G allocated to the kernel may not be fully used. This is a question of efficient use of physical memory when using the default setting of an OS, such as XP, and hence this type of discussion. We have a default 2G user space (for physical mem), but you can push it up to 3G so that you can make use of the additonal 1G physical mem for apps processes. The kernel uses the remaining physical mem which is bounded between 3G to 4G. The four apps each uses 1G of address space in the virtual address range.  The computer still benefits from the available 4G physical memory. The kernel has the last 1G and the four apps shares the use of the first 3G (minus some for BIOS and device drivers) of physical mem.  The only difference is that all 4x1G apps can not be loaded into physical memory at the same time because all your apps can only be loaded into the first 3G of mem.  So if there is no shared resources (lib, etc.), the round robin and LRU algorithms would control which libs and files will be paged out at any instant of time.  If each of the 4 apps has only a single process of size 1G and non of the files are shared, then only 3 apps can be in physical memory at any instant of time (this does not necessarily mean that only 3 apps can be 'running'at the same time.  In fact all 4 can be running at the same time, but only 3 can be in physical memory at any time.)

  • Anonymous
    April 10, 2010
    http://blogs.msdn.com/ntdebugging/archive/2010/04/02/how-to-use-the-dedicateddumpfile-registry-value-to-overcome-space-limitations-on-the-system-drive-when-capturing-a-system-memory-dump.aspx

  • Anonymous
    April 23, 2010
    I am using Process Explorer and having an issue.  I am trying to calcualate the commiting current.  When i go into add columns i do not see "commit charge".    which values do i add to get commit charge?

  • Anonymous
    May 26, 2010
    Very very great post. But Mark, there's a question concerning this section "In reality, not quite all of physical memory counts toward the commit limit since the operating system reserves part of physical memory for its own use". For this reason, the system commit limit should be a little less than the amount of physical memory and page files. But in my Windows 7 system, I have 1,833,392KB of physical memory (from Process Explorer) as well as a page file of also 1,833,392KB. At the same time, Process Explorer shows the commit limit of 3,666,784KB, just double 1,833,392. And another implicit question is, if the commit limit is equal to physical memory plus page files, how it could be "Not all the virtual memory that a process allocates counts toward the commit limit"? Where are those other virtual memories from, e.g. reserved virtual memory?

  • Anonymous
    June 20, 2010
    as always - thanks for your time and the very helpful article ;-) Best Regards from Germany Ramazan

  • Anonymous
    July 18, 2010
    Great article, but what about multiple pagefiles, which Windows allows?  How are those used?  I have this question using SSDs for a boot drive. Apparently it's recommended to not have a pagefile on the SSD, which have a write-limited life. Alternatives are RAMdisks or another spinner (traditional HDD). But I have a netbook with no other drive than the SSD, and only 2GB of RAM. On that I have 2 pagefiles, one in a RAMdisk, the other on the SSD.  I'd like to know which one will be used first and most.

  • Anonymous
    September 12, 2010
    Practical comment. Photoshop CS3   refuse to run without PF.

  • Anonymous
    December 04, 2010
    So if I have 1.5 GB of RAM in my HP laptop, what shall be the Custom initial size and maximum size, considering I want to get the best I can, out of my computer? Thanks in advance..

  • Anonymous
    January 09, 2011
    The comment has been removed

  • Anonymous
    January 18, 2011
    After reading this article, I have been running a machine with Windows 7 Ultimate x64 with 8GB of RAM and a 16MB paging file. The virtual lack of a paging file has shown me that it's not always necessary. I'm now back reading this article again contemplating the use of a reasonably small paging file for a Windows Server 2008 R2 machine with SQL Server 2008 R2 and 24Gb of RAM running under Hyper-V Server 2008 R2.

  • Anonymous
    January 28, 2011
    On my last machine, I put page file into a separate partition so that it wasn't included in my system partition backups, and I used FAT32 because I wanted to.  I also decided that the file might as well be 4 gigabytes, because that was plenty, I could afford to give up the disk space, and on FAT32 it couldn't be any bigger. Now I have a new machine to set up...  and someone is telling me that I should still have at least 300 MB of pagefile on volume C.  Is there a justification for that?  Something to do with successful system crash dumps, maybe?  I previously did what I liked and it seemed to work OK.

  • Anonymous
    March 24, 2011
    We are using software that is tied to 32-bit Windows operating system and we are running into major issues as we hit the PVM limits of the system.  We already have the large address aware enabled to allocate 3GB address space for our application.  Is there anything we can do to work around these limits (from the OS perspective), or are we stuck with our only options being upgrade to 64-bit OS or break-up the application into multiple processes? Thanks in advance! DW

  • Anonymous
    April 03, 2011
    @DW: If you want to use more than 3GB (3.3 with /USERVA= switch) from within x86 application, you should use EITHER  multiple processes OR use some mechanism p. e. AWE to indirectly manage further memory pages. (note: I'm not a Mark Russinovitch so I can be wrong :-)

  • Anonymous
    April 06, 2011
    Mark, I've read this series of articles and the Microsoft Windows Internals book. Thank you very much. I haven't found anything this informative since Peter Norton's books (way back when). I have an issue I can't let go. By design, 32-bit Windows total Virtual address space is 4GB. Thus for me - Pagefile Size + Physical Ram must be less than or equal to 4GB total. If the physical ram is 4GB and the pagefile is 2GB, then nothing in the pagefile is used by the system during normal operations. The pagefile would only be used for a crashdump. Of course, this "might" change if using an application that is AWE aware. By design, x64 total Virtual address space is 16TB (8BG User/8GB System). As you say in this article, "Windows can having paging files that are up to 16TB in size". KB Article 294418 lists the maximum paging file size as 256TB. They assume the 16TB limit and allow for 16 pagefiles. This doesn't make any sense to me as the virtual space is limited by the operating system at 16TB. I've seen this 256TB pagefile notation several times. I can only think that you would need a pagefile over 16TB if x64 supported some sort of AWE mechanism. So far, I haven't heard about one. If you are following up at this late date, I want to understand. Again Thanks.