What's wrong with disabling the Windows page file?

15

4

People say that you always need a page file, and that it will increase performance, but my Windows 7 is set to run without a page file. I simply don't understand why people say this - I have 6 GiB of RAM, and the only time I even came close to running out of RAM was when I was compiling Chromium, for which I temporarily enabled a page file.

Do I really need a page file* for a speed boost in typical situations? Why?

*I'm aware that crash dumps need a page file. I don't ever use crash dumps, though, so that doesn't matter.

user541686

Posted 2011-05-20T21:55:18.647

Reputation: 21 330

Answers

8

A pagefile will never increase performance, but it doesn't necessarily degrade it either (with proper memory management). Running without a pagefile, however, will only tend to increase your system's instability with respect to applications requesting memory that is not available for use.

Unless your OS is particularly bad at memory management, a pagefile with 6GiB of memory should see little use. That isn't to say it won't see any use at all; IIRC MS Windows is a bit crazy when it comes to paging things out even when there is plenty of memory available. (Why, I'll never know.)

However, what happens when you don't have the pagefile in use may be reason enough to enable it: hard crashes. Most apps expect to receive the memory they request. When they don't, they crash. (Ah, but the good-old-days of having to live in a few thousand bytes are gone..., and for all too many developers, so has the practice of dealing with memory management.)

If an app is built right, it'll fail nicely. (With luck, it'll not fail at all. But don't count on it.) With most apps, you'll have a fantastic failure on your hands. Furthermore, the more apps you have that come close to that limit, the more likely you are to see system-wide instability.

Case from my own experience. Windows XP, 4GiB, No page file. Perf was great. Until we started getting close to the 4GiB limit. Then things went nuts: apps would crash, menu items would only partially appear (or not at all), buttons would do nothing, etc. I switched back to the page file, even though performance was worse with it -- overall stability was simply better and more important.

Now, perhaps you don't use any apps or do work in your apps that would push 6GiB, but I can think of a few situations where you might get close: video editing, photography editing, audio mixing and production, etc. -- essentially anything where you are dealing with a lot of data (either working with, or streaming). When that data exceeds your memory capabilities, chances will be good that your app will just go "poof".

Kerri Shotts

Posted 2011-05-20T21:55:18.647

Reputation: 663

1Not true - a pagefile CAN improve performance, because the place of the unused data on the swap can be used for caching. This caused a such downvote for you. – peterh - Reinstate Monica – 2014-07-21T07:30:32.237

1The page file CAN improve performance. It increases the RAM available for all kinds of fast caches improving the program startup/load/operation performance. Without the page file, that precious physical RAM would be filled with unremovable junk. – Ark-kun – 2015-06-21T21:33:25.600

So, simply put (Yes/No): is it correct to say that, if I never use over 2 GiB of RAM, I *will not see a performance boost*? Or is there still a caveat somewhere, even with that precondition? – user541686 – 2011-05-21T07:31:43.577

9No, a page file never improves performance. It only improves stability. Paging, by definition, is a disk-level operation, and disk operations are always slower than RAM-level operations.

And, you are more likely than not, even with 6GiB (never exceeding 2GiB), that you will still experience some performance issues as Windows will still, frustratingly so, page unused processes out to disk. Whoever thought that was wise, I'd like them to 'fess up!) – Kerri Shotts – 2011-05-21T07:34:59.533

Okay. Maybe it's because it's what I wanted to hear, I don't know, but I like your answer. :P Sounds pretty reasonable, thanks! – user541686 – 2011-05-21T07:38:10.937

7

This article by Mark Russinovich will tell you everything you ever wanted to know about the page file.

I don't know if "cache" is the proper term to use with respect to what the page file does. A cache is a quickly-accessible temporary holding spot for data. An operating system "faults" things out to the page file when there is too much contention for physical RAM. So it's a stopgap for RAM overflow to prevent programs from crashing hard due to out of memory. But I do believe Windows tries to put things that haven't been accessed in a while in the page file (and Linux might do this too) so in that sense it is a cache, but not really its primary function.

Anyway, read the article. It will give you good guidelines on what to set your pagefile to. As @Sandeep Bansal says, there might be the occasional game that requires you to have one as part of a "requirements check" in order to run (but I don't know of any).

EDIT: This example can help you understand the role of the page file:

Let's say you have 512MB of RAM. You have a number of programs open, including a minimized browser itself consuming 250MB of RAM, and total RAM usage of everything running at that moment is 500MB.

So then, you start up another program (say a word processor) which wants to allocate 150MB of RAM. Out of memory. However, if we have a paging system, then the memory pages containing your minimized browser can be paged out to disk. So then the new program can load.

Now let's say you want to go back to the browser after a bit. Well, it needs to "page in" what it just sent to disk. If there's enough free RAM at that moment it can do that without a problem. If there isn't, something else has to be paged out first. If there's a lot of programs competing for the CPU and there is constant paging, then things get slow and you have the condition known as "thrashing." All this paging in and out causes slower performance, but it avoids programs from "hard" crashing due to out of memory errors. That is the purpose of the paging file. Too much paging, i.e. "thrashing" is likely no better than a program just giving up because it can't get any more RAM most of the time.

Now, you can see how if algorithms exist to anticipate what might not be being used at a given moment, then the operating system can "pre-page" things that it doesn't think will be used right away. So this accounts for Windows using the page file where it exists even if it does have enough RAM. It's trying to make as much RAM available as possible. Windows is like Linux where free RAM acts as a disk cache so if the balancing act is played right it can contribute to overall performance. This is all part of OS design and why it takes 10 years to get a good operating system out of thousands of programmers.

So, to actually answer your question as well, that is the only thing wrong with disabling the page file. Going back to the example I provided, without the page file you'd simply be unable to start your browser, or poorly written programs that aren't defensively programmed to anticipate OOM errors might act really strange.

LawrenceC

Posted 2011-05-20T21:55:18.647

Reputation: 63 487

The "safe" amount depends on the programs you run and when and how much they ask for memory. There isn't a specific amount of RAM that makes it OK to turn off your page file, it's the combination of programs you will run at once. Some programs are very deterministic and predictable and their memory requirements can be easily estimated, other programs, like browsers, are not. – LawrenceC – 2015-06-18T21:09:50.057

@ultrasawblade: I still don't understand: The point of any sort of "cache" is to prevent a trip to the disk. If you're going there anyway, why not just grab the file from wherever it's located? What's the point of the page file? – user541686 – 2011-05-20T23:46:37.753

@ultrasawblade: Also, regarding the article: It says, in general having [a page file] will mean more usable memory being available to the system. Wait, what? More available memory? Is > 3 GiB of permanently unused RAM space not enough? (Confused, since I rarely use over even 2 GiB.) – user541686 – 2011-05-20T23:58:04.187

2The page files are NOT cache! If your ram gets full and you still want to make sure it still looks like your system has more available ram, then it will start copying data from ram to your disk (from processes that seem to be sleepy) so you still have available ram for your new processes! – devoured elysium – 2011-05-21T01:41:59.043

2@ultrasawblade: The objection I have against your edit is that your example specifies a 97% RAM usage (500/512), whereas my example specifies a 33% RAM usage (2 GB out of 6). I was not asking about what happens if I get close to the limit; I'm already well aware what issues that causes. I was asking about what happens if you've still got quite a long way to go, where no thrashing or anything of the like would (should?) occur. If you can make the same argument for my case (6 GiB RAM, and 2 GiB being used) then that would be a lot better; otherwise, it simply doesn't address my question. – user541686 – 2011-05-21T03:31:18.153

It might give you a small benefit if you do continuous heavy disk I/O (such as web-accessible databases, extremely heavy file serving or heavy video/audio processing), as if you have a page file (relatively slightly) more physical RAM can be free and available for disk cache. Of course I don't know how the internal Windows algorithms work here so I could be wrong. If not, there isn't much benefit. I would think you'd get a better overall benefit by turning it off in your situation with that much RAM. – LawrenceC – 2011-05-21T03:36:43.783

@ultrasawblade: Okay so what I'm understanding is that pretty much the answer is that there's no benefit, assuming I don't go over something like 2 GiB, right? – user541686 – 2011-05-21T03:39:18.567

3+1 for the Russinovitch link. There's the answer. If you want to give up a safety mechanism to prevent possible crashing, that's your perogative. Windows will function just fine without the page file, unless it decides not to. ;) – Kara Marfia – 2011-05-21T03:48:53.430

@Kara: Two issues: (1) is that really for "safety"? So if instead of 6 GiB of RAM I had 6.5 GiB of RAM, then I could turn off the pagefile? Is any amount ever "safe", and is it really reasonable to turn on a pagefile for "safety" if you never go over 30% of your memory? (2) I wasn't asking about correctness, but about performance -- do I get a boost? – user541686 – 2011-05-21T04:21:24.757

If Windows and everything installed on it could be relied upon to work perfectly every time, than yes, you could say confidently that you would be able to predict NEVER passing that 6GB mark. But Windows isn't like that. Nothing man-made is like that. Your question was "what's wrong with disabling the page file". It sounds like you meant to ask a different question. – Kara Marfia – 2011-05-21T14:43:45.097

2

A page file isn't just for crash dumps to be stored, it isn't essentially made for that.

The page file exists so it can store data that RAM doesn't need to hold, it's like a cache for items that don't need to exist in memory thus providing more RAM for other things.

You're right that you may not need a page file if you have 6GB RAM, but you may need a page file for certain items, I remember that a few games require a page file and also it can be useful if there is one.

There's no harm in creating a 500MB Page File just to avoid problems if a certain process needs it.

Sandeep Bansal

Posted 2011-05-20T21:55:18.647

Reputation: 6 168

But my question is: let's say I never use more than 2 GiB of RAM. Does enabling the pagefile give me a speed boost anyway? ("It doesn't hurt" is different from "Yes, it gives you a benefit".) – user541686 – 2011-05-20T22:04:44.473

Well with 6GB RAM you won't notice a thing, even though there's RAM available the Pagefile will always be used for other things. I have 4GB, never really go above that. But I have a 1GB Pagefile just incase, like everyday PC's have 500GB+ HDD space now, so at least 500-1000MB won't be a loss – Sandeep Bansal – 2011-05-20T22:10:18.680

@Sandeep: Hm... what exactly are those "other things"? The very reason I don't turn on the page file is that I don't understand why Windows would use the hard disk when there's so much RAM free, so I'm curious what those "other things" are. – user541686 – 2011-05-20T22:11:00.287

It's the same as Linux, why does Linux use swap space when it has RAM to access. The pagefile holds files that haven't been used for a period of time away from RAM. – Sandeep Bansal – 2011-05-20T22:35:03.120

@Sandeep: I have no idea why Linux does it either, same difference for me. What's the point of holding files in the pagefile though? If they're not in RAM, why not just read them from wherever they're actually located on the disk? – user541686 – 2011-05-20T22:36:33.230

I think it may have just been something continued from the Win 2000/XP, and older versions of *nix where RAM availability was an issue. It can serve a purpose if you do tend to use most if not all your RAM – Sandeep Bansal – 2011-05-20T22:38:35.910

@SandeepBansal: "if a certain process needs it" does not exists AFAIK, an application can't really do that on demand. While it is possible to provide a check if a page file is being used, most computers have a page fault by default. Adding such a restriction is bad anyway, because the size is automatic by default and I could as well just create one using the minimum amount. But I agree with the rest of your answer... – Tamara Wijsman – 2011-05-20T23:19:45.423

@Sandeep: But like I said, I never go above 2 GiB anyway, so I'm not seeing why that 500 MB of cushion is so special. Would your answer have changed if I'd told you I had 6.5 GiB of memory instead of 6 GiB? (i.e. Would I still have needed an extra 500 MB "just in case"?) – user541686 – 2011-05-20T23:48:21.920

@Tom: Not sure what you mean by While it is possible to provide a check if a page file is being used, most computers have a page fault by default.... page faults and page files are pretty unrelated. – user541686 – 2011-05-20T23:48:52.747

@Mehrdad Since you stated if you had 6.5GB the answer would still be yes you may possibly still need a page file since a program could possibly be set to utilise the swap, or even maybe core areas of windows may need it. The page file obviously will hardly ever be used due to the amount of RAM (6GB). If you have looked at readyboost, that is a similar technology, but with the use of USB Flash Drives. It's just acting as a page file. Sorry if the addition of readyboost just created further drama on the answer haha – Sandeep Bansal – 2011-05-21T01:18:26.520

@Sandeep: ReadyBoost does not act like a page file. Obvious difference: If you somehow manage to remove your page file while the system is running, your system will crash. If you unplug your ReadyBoost device, it won't. ReadyBoost is not "more memory", it's just a non-essential cache that's completely different from the page file. – user541686 – 2011-05-21T01:21:35.270

1

The first step is to understand what a Cache is, or rather, what the different caches are used for.
The CPU has a small internal cache which allows it to store OP results, flag states, and calculated addresses. On a dual core I believe that internal cache is about 1mb. It's is extremely fast, only accessible by the CPU internals, and the most affected by heat in an overclocked CPU.

The level 2 cache acts as a high speed buffer for CPU to Memory transactions and also holds code threads collected by prefetch. On a dual core I believe a tyical installation would have 6mb of lvl2 cache. It is very fast, though slower that internal cache memory, is accessible only to the memory controller and CPU, and resides on a dedicated line on the bus.

A page file is indeed a cache, in that it stores data which may or may not be present in memory. An O/S can use the paging file for various tasks, one of which is to save the current state of a data file that has not yet been committed to disk. When a pagefile does not exist, it is up to the third party application to provide this functionality internally. The trouble with this scenario is that many programs do not behave well when it comes to garbage collection, and you are left with spurious .temp files being left on your disk. These remnants are not part of the installation manifest and can hinder an uninstall procedure and also degrade disk access speed.

My opinion is that a swap file is normally a good thing to have. Indeed, if your system is highly populated with Ram and it is dedicated to 1 specific task, and that application takes care of all these things then a swap file may not be needed. One example may be an Arcade Video Game that runs on the windows platform, these are typically installed with only the drivers needed for the devices present and are not likely to suffer from driver contention. For the most part though, most applications do not take care of all the potential issues that could arise and especially those that include impact from other third party applications and driver contention.

Though you may notice a low to moderate decrease in performance in the shortterm of adding a pagefile, longterm the performance should remain consistent. Not having a pagefile may seem faster in the beginning, but over time performance will degrade considerably.

Steven Malm, MCP.

Steven Malm

Posted 2011-05-20T21:55:18.647

Reputation: 11

"When a pagefile does not exist, it is up to the third party application to provide this functionality internally." --> Not quite sure what you mean; programs don't really care if there's a page file there or not. – user541686 – 2011-05-22T18:47:03.043

0

Personal experience

Right now my laptop with 8GB RAM has problems preventing the creation/usage of the page file. My life is hell. I constantly get "Low Memory" prompts, apps crash, etc. Using 3 programs that eat 1-1.5 GB each (say, web browser, Visual studio with special plugins, etc.) is walking on thin ice.

Another argument

Using data from the physical RAM cache is very fast. The more "free" physical RAM you have the bigger cache it can hold. The more dormant data the OS can move from physical RAM to the page file, the more physical RAM is freed for caches of frequently accessed data.

Suppose you play some game which loads the location data when you change location. You also have web browser running which leaves, say 2GB to the game, which is enough for a single location. Without a page file, every time you change location, the data will be slowly loaded from the HDD. With a page file, your unused web browser data would be sent to the page file, and the precious physical RAM will be used to store the data for several locations resulting in much faster location load.

Ark-kun

Posted 2011-05-20T21:55:18.647

Reputation: 129