Windows – Why does Windows 7 use the page file when there’s free physical RAM

memoryresource-monitortask-managerwindows 7

I am using Windows 7 64 bit with 8G ram. After some use, I feel Windows is getting sluggish. The drive is thrashing. When I look at the resource monitor and disk activity, I see a few instances of use of the page file (c:\pagefile.sys). I check the physical memory and I see about 2.3G available memory and 700M free memroy.

Why doesn't Windows use more of the free memory and less of the page file? Does it need to leave some x amount of free ram, how much would that be? Is it a percentage of physical ram?

My plan is get more ram and an SSD for the main drive. Meanwhile I am suffering from slow performance.

Best Answer

First, don't place your page file on an SSD. While SSDs have gotten better about wear leveling, the page file is written to frequently and it will degrade your SSD much faster than general use.

What a lot of people don't understand is that windows never really has free memory. There's a few MBs which are kept free for burst demands, but otherwise, the difference between active in-use application memory and the total memory is generally consumed by what is known as "standby" memory.

System memory

These are memory pages which can be dumped if needed (standby memory is a great, big cache), so from an application standpoint, it's available, but they are not by any means not being used. Usually, they function as disk cache, or a pagefile cache.

Windows' goal is to keep the data most likely to be used in this standby cache, based on usage patterns. To use a contrived example, let's compare the relative value of the private memory of a program like Windows Update (usually configured to run once a week), over the caching the contents of your desktop in this standby memory:

For a good majority of the time, Windows Update is sleeping. It's holding up memory and for the most part, doing absolutely nothing of value with it while it's waiting for the schedule to come around. The contents of your desktop folder on the other hand, might be queried constantly, especially if you like to save files to it.

In this case, what Windows will do is page out the memory allocated to Windows Update (even though memory isn't "full", and use the space made available in RAM to cache the contents of your desktop. This results in better performance for you.

Windows is making thousands of these decisions and managing a disk cache for hundreds of files being constantly written to by background services while trying to balance this with memory demands of active applications. Sometimes it gets it wrong for a moment, and we might have to wait for it to page data back into memory when we switch to an application that's been sleeping in the background for a while. But what you have to think about is if it had kept that application completely in memory, how many other applications would in turn be bogged down waiting for disk writes and reads to complete, or themselves be forced to page out? What if those were applications you were using in the meantime?


Applications frequently allocate memory pages which are used very rarely, such as start-up code (used once and then not needed), shut-down code (used once and then not needed), or update code. It's not practical to keep all this in memory when there are much more important uses, so once Windows identifies sections of code that haven't been needed for the current operation of an application, it happily pages out those sections to the pagefile, even if it technically could retain them in memory.

(And actually, depending on the applications, systems might frequently allocate more memory than they actually have, expecting most of it to wind up paged out. If you're looking at a detailed memory breakdown, the "Commit" or "Commit" charge is how much memory Windows has allocated to various applications. The pagefile is used to provide guarantees for this memory, even if it doesn't have enough physical RAM to cover it.)


I just noticed you did make a distinction between available and free memory in your question; My apologies if you feel lectured and already knew the difference. Ideally, free memory is always 0. However, while standby memory is memory that can be released, it's not always memory that can be released quickly. If I try to write a 1GB file to disk, windows is going to stick it in a disk cache in memory if it can, and then slowly write it out to the harddrive in the background. If an application needs to request 50MB of additional memory, but none is available because this huge disk cache is still being flushed out, then the application will hang until it's available. Keeping a small buffer on hand allows the system to resolve this issue with minimal lag from the user's standpoint. You might also wind up with larger-than-normal buffers if Windows just emptied part of the standby cache or released a lot of in-use memory, but hasn't filled it with new cache data yet.