Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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.

share|improve this question
1  
Just because it is writing/reading to the page file does not mean it us using it, it may just be updating it so it can dump the memory quicker if there is a sudden demand. I recommend running performance monitor or do a deep diagnostic and seeing what is causing the sluggishness. –  Scott Chamberlain Aug 3 '12 at 17:49
    
Having more than 8GB of RAM will not increase performance in 99.(9)% of cases. Have you stuffed your mobo full of cheap low frequency/high latency RAM chips? Replacing them would be a better idea than adding more. –  kotekzot Aug 3 '12 at 18:41
    
@kotekzot That depends. I've generally found RAM latency to be somewhat negligible in most bottlenecks. If he has enough memory that he's not having to wait for applications to be paged in when he alt-tabs through all of them, then the next biggest bottleneck by several orders of magnitude is almost always the harddrive, and an SSD will fix that right up. –  Darth Android Aug 3 '12 at 18:46
    
@if I have more ram, I can put the page file in a ramdisk which is much faster than HD access. It's a Dell laptop workstation level so I am sure the components are not cheap. I am aware that laptops have slower hard drives and IO subsystsem than desktops. –  Tony_Henrich Aug 3 '12 at 23:06
add comment

4 Answers

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.

share|improve this answer
    
What a lot of people don't understand is that windows never really has free memory... I don't agree with your statement. If that were the case, Windows would be constantly swapping. Windows does use some memory for disk caching, but on a box with 8GB of memory, you're going to have lots of free memory. –  FrankComputerAtYmailDotCom Aug 3 '12 at 19:24
2  
@FrankComputer See the screenshot I posted for my 8GB work system: 6300MB in-use, 1700MB standby disk/cache, 42MB free. Looking at my home system (32GB memory), you're actually correct, but just at the wrong threshold: 9.2GB in-use, 14.5GB disk cache, 8.6GB free. You'll have free memory if windows has simply run out of things to cache, but that threshold is pretty high. Windows is not constantly swapping because disk cache is not swap space - it's passively cached when files are requested and not in the cache. You don't notice the times that it pulls from the cache and there's no HDD activity. –  Darth Android Aug 3 '12 at 19:38
    
That's because Windows detects how much total memory the system has and by default assigns xGB for pagefile.sys and xGB for disk caching, but you can fine-tune these and have more free memory if desired. I have a Vista-SP2 laptop with 2GB memory. Its free memory averages 1GB and my disk light rarely blinks. –  FrankComputerAtYmailDotCom Aug 3 '12 at 19:55
1  
@FrankComputer: If your system is performing well, it's not because of the free memory. Free memory is memory the system is not using, and it can have no more effect on performance than memory sitting on your desk. The only way to improve performance with memory is to use it, so if it's free, it's not being used to improve performance. Making more memory free means using less, making performance worse. –  David Schwartz Aug 3 '12 at 22:47
1  
Darth Android, this is the clearest, most succinct explanation I have read explaining why a page file is highly recommended and why memory use in modern operating systems is so much more complicated than the Task Manager would have you believe. I wish more software developers understood these fundamentals, let alone average users. –  bart Jun 6 '13 at 18:23
show 9 more comments

It's called planning ahead.

Writing memory pages to the pagefile when there is still plenty of RAM is a good thing. As soon as a program requests more memory than there is free, the OS can start clearing out space as soon as possible. Better to prepare now than later.

If the OS were to wait around, then you run into a performance bottleneck. If a program asks for more memory than is available, now you have to wait until the OS writes out changed memory block, and then free them up.

share|improve this answer
    
With 16G+ and with light programs, the times when a program asks for more memory than what is free is much less than the frequent use of the page file. So for those cases, it's better to use some of the free memory and less of the page file. There's no one solution that fits all cases. –  Tony_Henrich Aug 6 '12 at 5:03
    
I don't think you get it. It doesn't have to be one or the other. Windows can write to free memory and write to the pagefile. It isn't like writing to the page file or writing to memory. –  surfasb Aug 9 '12 at 3:26
add comment

I have had page file turned off for the last 7 years. Actually it's the first thing I do after fresh install. Never had any problem with it. (Actually I had one - game called "titan quest" performed a very stupid check at startup so I created a 4 MB pagefile only to make it happy and turned PF back off later). As for the original question. Windows uses our RAM for disk I/O cache. For some reason it thinks the disk cache is equally important to the active programs code and data. And there's no way to limit disk cache size. It's there by design and we can't do anything about it... Oh, wait! We can! Just turn the pagefile off. Running applications that are heavy on RAM? Buy more RAM or close one app before launching another. You can use Process Explorer to see how much memory is used at any given moment. Personally I have 8 GB RAM both at work (vmware + virtualbox + eclipse + firefox + delphi + adobe premiere + skype + more background programs ) and at home (heavy gaming) and can't remember when was the last time I saw the "low on memory" warning.

share|improve this answer
add comment

All these comments and the correct answer is missing. Turn OFF your page file. It isn't needed with 8GB RAM,and if you need more RAM, buy it. pretty simple really.

share|improve this answer
1  
Windows is quite clever in determining what (not) to put in the page file. With the exception of some almost purely theoretical scenarios, turning it off will harm performance, even with 8 GB of RAM. Even if the correct answer were missing, this is certainly not it. –  Marcks Thomas Dec 17 '12 at 0:36
1  
Got any evidence to back up your "harm performance" claim? I present an MS article support.microsoft.com/kb/889654 –  a2552308 Dec 18 '12 at 1:34
2  
Simply put: page files can only increase disk activity... and windows isn't smart enough to not use it at all if it has lots of RAM. On an SSD system this may not be too noticable, on a spindle system this may affect application performance a lot. Refer original poster. –  a2552308 Dec 18 '12 at 1:42
1  
It would be nice if the OP could disable it and report back, but given the timing that probably isn't going to happen. I run many applications on a system that I never turn off. I usually have at least 20 applications open at any one time and I always expect to be able to switch to another application at any time and have it respond immediately. This isn't possible when running a page file because Windows will always swap out pages that haven't been active for a while. Many people may not notice the difference because of the way they work, but I do, and page files make the way I work slower –  a2552308 Dec 18 '12 at 21:37
1  
Relevant section from MS article: "However, as more RAM is added to a computer, the need for a page file decreases. If you have enough RAM installed in your computer, you may not require a page file at all, unless one is required by a specific application." I couldn't find the relevant sections from the many articles you linked, maybe you could quote the relevant sections? –  a2552308 Dec 18 '12 at 21:48
show 4 more comments

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.