28

From my personal experience I've noticed that disabling the page file in Windows XP has given me, in general, the most speed gain out of any other software change I can make. Obviously this has to be done when a significant amount of RAM is available. Typically I find that it works nicely with +2GB of RAM. The only issues I've ever really had were loading up Adobe Photoshop.

Is this really a speed improvement or am I imagining it?

Note: In order to actually turn it off, you must not just set it to 0MB, but disable it. Otherwise Windows will just expand it when it needs to in order to meet its needs.

1
  • 10
    Attention: There is only a limited amount of memory given to drivers, called the non-paged and paged pool memory sections. A page file is necessary for when the paged section gets full, as a gamer I have seen a game complain about paged pool memory just because I had my page file disabled on a 8 GB system. Conclusion: Page files are necessary, they prevent paged pool depletion and actually do speed up your system. Oct 24, 2011 at 16:21

9 Answers 9

19

Windows XP flushes minimized applications to disk like crazy.. try it yourself, start downloading a large torrent and minimize everything. Pretty soon almost all of your RAM is used as file cache for the torrent instead of your other applications. Disabling the page file will prevent this behavior.

In Windows Vista and Windows 7 though, the system handles this scenario much, much better.. so I'm not sure disabling the page file in these versions will do much of a difference.

Some games require you to have a page file even when it's not really needed, I noticed this recently when trying to play a game demo I downloaded from Steam. Even though I had 6 gigs of RAM available the game refused to start until I created a tiny, tiny page file.. sigh

Personally, when I have plenty of RAM, I prefer to go without a paging file.

3
  • I've been going without a page file on WinXP since I asked this question and it's been great. I haven't really tried it on Win7 yet so I can't say whether or it would be worth it for newer versions of Windows. Dec 15, 2013 at 18:26
  • I have tried it on Win7 and did not have a great experience. Since SSDs are available not, it makes sense to just have a page file Jul 8, 2015 at 15:46
  • Having a pagefile or not has nothing directly to do with file cacheing behavior. Jun 30, 2017 at 20:32
25

Don't mess with it, let Windows figure itself out.

This ServerFault answer is the most excellent explanation of why:

Many people seem to assume that Windows pushes data into the pagefile on demand. EG: something wants a lot of memory, and there is not enough RAM to fill the need, so Windows begins madly writing data from RAM to disk at this last minute, so that it can free up RAM for the new demands.

This is incorrect.

The punchline:

Removing pagefile entirely can cause more disk thrashing.

11
  • 14
    How would removing the page file cause ANY disk thrashing? If anything it should stop thrashing. Windows will give an error if it runs out of RAM -- it's not going to decide to use swap if it's been disabled. Jul 29, 2009 at 2:11
  • 2
    d03boy, read the SF post. If you have to move active process memory out of ram, it will cause a LOT more disk activity. Jul 29, 2009 at 2:18
  • 3
    @d03boy: The answer is in the linked post. Basically, if you use too much RAM, the HD is going to be used in some way. If you remove the page file, the HD is still used to potentially store the program code (simply reading it from the original files on demand) when more RAM must be allocated.
    – Sean
    Jul 29, 2009 at 2:18
  • 1
    @Factor, Windows simply gives you an error if it uses too much physical RAM. It's not going to move anything out of RAM AFAIK @Darth, the linked post makes it sound like it's doing that whether paging is on or off anyway Jul 29, 2009 at 2:27
  • 2
    This is not true for Windows XP though, Windows XP has horrible memory management. Read my answer.
    – zidar
    Aug 11, 2009 at 13:16
7

from microsoft answer "disable swap file"

http://social.answers.microsoft.com/Forums/en-US/w7performance/thread/0bd8a75c-2607-4468-8342-c35ea82ea670

Ken Blake, Microsoft MVP

is there any performance gain from that ?Thank you.

Can you? Yes. Should you? No, definitely not.

Is there any performance gain from doing that? No, and there's a possible performance loss.

First of all, 2GB is not a lot of RAM, it's the minimum amount that most people should have.

Second, if you don't have a page file, you can't use all the RAM you have. That's because Windows preallocates virtual memory in anticipation of a possible need for it, even though that allocated ay never be used. Without a page file, that allocation has to be made in real memory, thus tying up that memory and preventing it from being used for any purpose.

Third, there is never a benefit in not having a page file. If it isn't needed, it won't be used. Don't confuse allocated memory with used memory.

Ken Blake, Microsoft MVP (Windows Desktop Experience) since 2003 Ken Blake

3
  • What about thrashing? Is there less HD use if it's disabled? This doesn't seem like the entire answer. Not to mention, this question is about XP and this answer is about Win7 Jan 20, 2011 at 18:39
  • I don't think that MVP is correct, given sufficient memory you can disable the swap file; just make sure you don't run out of memory. Jan 23, 2011 at 13:15
  • 1
    @JoePhilllips - No, simply put, if Data memory+Program memory exceeds system memory with no page file then the space available for programs is reduced to make room for data, as programs can always be re-fetched from the original program files. So, if you have 8GB memory, 6GB of data & 4GB of applications, your OS only has 2GB to share between those 4GB of programs. It would be constantly reading in code & thrashing the disk. If only 4GB of data was actually needed and you had 2GB page file to swap the rest into, then the OS would be able to use the other 4GB for the programs, so no thrashing!
    – Mark Booth
    Dec 9, 2011 at 14:55
6

I would say enable.

No matter how much RAM you have, there will be scenarios when a page file is, at the very least, useful. Also, it should be noted that when there is a page file, much of the Windows runtime is offloaded there for most of the time. The reason? While it's needed in memory, it isn't needed at the moment. Putting it in the swap file may means it takes longer to access, but it leaves more RAM free for the programs you are actually using.

The reason your performance increased is because you were forcing the whole system to be loaded into RAM, which is admittedly much faster. However, my guess is that when you start using a bunch of programs at once, especially memory-heavy ones like Firefox and your Photoshop, that improvement will go right out the door.*

However, it is possible that you will never encounter that problem simply due to your computing habits. I know that if I tried to turn off the page file, I would not enjoy it one bit. So if you really want to, try leaving it off for a while and see what happens, you can always turn it back on again later.

*"That paragraph was a fair amount of speculation" /disclaimer ;)

3
  • I'm have 4GB of RAM now since I've recently upgraded (although winxp only sees about 3.5) and I've had the page file off for a few months without any issues at all and only one or two reboots. I do use fairly heavy programs (including photoshop) without any issues so far. Jul 29, 2009 at 2:18
  • In that case, feel free to ignore my advice and do what seems to be right for you. Although Factor Mystic's post has a much better argument for the same conclusion, so at least keep what he's saying in mind ;)
    – Sean
    Jul 29, 2009 at 2:21
  • Maybe I will turn it back on and see if it helps. I just can't imagine constantly writing to swap is good for my hard drive though. Jul 29, 2009 at 2:39
5

I would say enable but move it to a second drive, preferably one not in use by some other I/O hog. That has often given me better speed than disabling the pagefile entirely. Of course, maxing RAM is a good parallel optimization.

1
  • 1
    If You do that, make sure You are moving the page file to another physical device. Moving it to another partition on the same device is a waste if time, unless You have an industrial-grade hard drive (like SCSI). Apr 25, 2012 at 20:06
3

I disable the swap file on 32-bit Windows systems with 4GB of physical memory. Having virtual memory on isn't going to add any more addresses to the system, and having it off means I never have to wait for Windows to swap in or out.

6
  • 6
    What timing tests did you run, and under what sorts of loads? Jul 29, 2009 at 2:31
  • 2
    No hard data == still subjective anecdote
    – romandas
    Jul 29, 2009 at 3:19
  • 4
    Of course it's a subjective anecdote -- did I ever claim otherwise? I'm not sure why people are asking for timing data: I don't run servers on Windows (unless I have to!), I run my personal desktop and gaming machine on it. And for such a machine, subjective response is all that matters.
    – kquinn
    Jul 29, 2009 at 3:53
  • 1
    And you never ran more than process as a time, I suppose? Even on a 32 bit system, more than 4GB of physical RAM can be allocated at any given time. You can even allocate more than 4GB of RAM to a single process by using the virtual memory APIs to remap sections of your address space.
    – Eclipse
    Jun 29, 2010 at 21:55
  • 1
    Er, did you mean more than 4GB of Virtual RAM can be allocated? When all physical RAM is used up, you'll start to get paging errors from the MMU, which'll cause swapping. With no paging file, that's going to be swapping in of whatever DLL/EXE data got thrown out. With a paging file, it'd be whatever got written to the page file. Jul 1, 2010 at 9:33
3

I disable the swap file on 32-bit Windows systems with 4GB of physical memory. Having virtual memory on isn't going to add any more addresses to the system, and having it off means I never have to wait for Windows to swap in or out.

No. Address space is as follows: every PROCESS has its own 31-bit address space (lower 2GB) and kernel has its own 31-bit address space (always same, regardless of which process owns current thread). This gives you 2GB * number of processes of available user-mode address space. Without a swap user-mode space is limited to physical memory size minus kernel memory size (usually around 200 MB). Of course, there may be some artificial limit on how much virtual memory your system can allocate, but I'm not an expert in Microsoft's licensing policies.

Also, note that disabling swap does not necessarily mean that there will be no page-faults resulting in disk access. The swap file is not the only file that memory is mapped to. Every executable file (that is, .exe or .dll, except kernel mode drivers) has its own disk backup - namely, the exe file. Of course, pages that have been modified in-memory, such as writable data segments, IAT, or even code segments (in case of packed executables, for example) need separate swap-backing, but vast majority of code/static data/resources do not need swap and... can be removed from memory when system is low on resources. When the process needs an access to such data, page fault and disk access will occur, whether swap is enabled or not.

2

Sean Nyman previously said "especially memory-heavy ones like Firefox and your Photoshop, that improvement will go right out the door."

I just wanted to add that in Firefox, if you type about:config into the address bar to go to the advanced settings in Firefox, you can add a new string for browser.cache.disk.enable and set the boolean value to false and this will force Firefox to cache only to RAM. You can also add the string browser.cache.disk.capacity and specify a value to control how much space in RAM Firefox will use for the browser cache. I hope this helps. I have mine set to cache in RAM and Firefox is always super fast.

I also have an SSD drive for the system drive in this laptop, with a 500GB rotary drive in the secondary bay for storage, and I set the TMP, TEMP, and Temporary Internet Files folders to point to the rotary drive in Windows 7 Pro, along with moving my pagefile.sys over to my rotary drive on D: and my system works very fast like lightning. I have 4GB RAM anyway, so I don't think Windows 7 even uses the pagefile much, but what is the harm in leaving it turned on?

1
  • No matter how much memory you have, windows likes to use the page file for some reason Apr 16, 2010 at 23:18
0

Disabling the swap file is perhaps the single most dramatic improvement you can use to increase the performance of your computer. In the typical scenario, most laptops use physical magnetic hard disks which have moving parts. These drives are very slow when compared to the speed of the memory in your computer. So if you have the ram to force windows to stay "within it's means" and never write out to the disk, it will only slow down when it has to hit the disk for a file not already in memory. Everything in memory will run significantly faster. The idea is to cache the entire operating system so it only reads or writes to a physical disk when it needs something not already in memory.

RAM read/writes happen in nanoseconds versus milliseconds on physical magnetic disks.

Now something to consider is that there are now new swap file options becoming practical. If you use a solid state disk or you get windows to put the swap file on a SD card, you will also experience significant performance increases.

Just my $0.02

2
  • 4
    Disabling swap doesn't mean everything stay in memory. It means what gets flushed out of memory has to be read back in from it's original location on disk when it's needed. This means your system will be slower. See the SF post I link in my answer. Jul 29, 2009 at 2:21
  • 3
    Which is precisely why you optimize it so it to never needs to hit the disk. I have done this before and it does work.
    – Axxmasterr
    Jul 29, 2009 at 17:31

You must log in to answer this question.

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