15

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.

0

5 Answers 5

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".

5
  • 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
    Commented May 21, 2011 at 7:31
  • 9
    No, 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!) Commented May 21, 2011 at 7:34
  • 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
    Commented May 21, 2011 at 7:38
  • 1
    Not 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
    Commented Jul 21, 2014 at 7:30
  • 1
    The 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
    Commented Jun 21, 2015 at 21:33
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.

10
  • @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
    Commented May 20, 2011 at 23:46
  • @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
    Commented May 20, 2011 at 23:58
  • 2
    The 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! Commented May 21, 2011 at 1:41
  • 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
    Commented May 21, 2011 at 3:31
  • 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. ;) Commented May 21, 2011 at 3:48
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.

11
  • 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
    Commented May 20, 2011 at 22:04
  • 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 Commented May 20, 2011 at 22:10
  • @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
    Commented May 20, 2011 at 22:11
  • 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. Commented May 20, 2011 at 22:35
  • @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
    Commented May 20, 2011 at 22:36
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.

1
  • "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
    Commented May 22, 2011 at 18:47
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.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .