Sunday, July 13, 2008

Disable Windows Page file, save your hard disk

>

There are lots of myths and confusion surrounding Windows page file, for instance, this utter rubbish "thumb rule" that the page file should 1.5 times the amount of physical memory. Then there is the question of whether to use the page file at all. The page file is intended to serves as a substitute for physical memory, the RAM. In early days, when RAM was expensive it made sense to allocate a major portion of the system's memory requirement to the page file, to reduce cost. Today, cost is no longer an issue. 2 GB RAM has become the standard for every new PC. With so much memory available is there any logic to use the page file?

Why you should turn off the page file?

The problem with Windows is, no matter how much physical memory is installed on the system, it will always use the page file constantly swapping data between the RAM and the hard disk. Every time the page file is accessed, the elaborate system of sliders, arms, actuators and motors inside the hard disk are stirred into action. The spindle rotates and the arm moves repeatedly to and fro over the platters reading and writing bits of information on the hard disk. All throughout a session the operating system uses the page file thousands and millions of time! Look at the screenshot below, under the Page Fault column. Those figures indicates the number of times the page file was accessed.

task-manager

Now, you don't have to be a rocket scientist to realize that the more you use a device the less the period of life the device is going to have. This is particularly true for mechanical devices, devices that have moving parts, like the hard disk. Due to friction between various parts and stress from continues usage a hard disk wears out. This is the reason why hard disk and optical drives failure is so common while motherboard or processors rarely fail because of the absence of mechanical parts.

Disabling the page file will significantly reduce the wear and tear the hard disk suffers, and will extend the life of the hard disk. Besides, unused RAM is wasted RAM. What is the use of having GBs of memory only to leave it idle? Of course, you must have sufficient amount of RAM on your system to disable the page file. How much RAM is sufficient depends on the usage of your computer. If you have anything more than 1 GB, you can turn off the page file. If you feel that your computer might require more than the amount of RAM you have, then instead of turning of the page file set it to the minimum value of 2 MB. If the memory usage suddenly shoots up Windows will automatically increase the size of the memory temporarily. You won't be able to eliminate page file access completely if you set a value, though you will be able reduce it.

Regarding change in performance, you won't notice a difference. I have turned of the page file on my computer and it feels good to know that my hard disk is not thrashing.

11 comments:

  1. I turned off page file. Some programs won't load. Windows XP complain not enough memory.

    ReplyDelete
  2. Yeah, some applications have problems with a disabled pagefile. They always seek to use the pagefile even though there is plenty of space in RAM.

    First verify whether you have really run out of memory. You can get that info from task manager. If yes, that means you cannot afford to have pagefile disabled. Either turn it ON or buy extra memory.

    ReplyDelete
  3. This article is extremely inaccurate. For one, relating the page faults column to hard faults to the pagefile is false. The page faults displayed in the Task Manager is the sum total of all faults on the system. Soft or hard. Most ar probably soft meaning it was a fault for a page that was already in memory, probably on the standby list.

    Also, if you don't have a page file you won't be able to gather a crash dump from that system. You need dumps to be able to diagnose a system crash.

    This is just more misinformation on the web about paging and Windows.

    ReplyDelete
  4. @DH: This is what Microsoft says about the Task manager's page fault column:

    Number of times data has to be retrieved from disk for a process because it was not found in memory. The page fault value accumulates from the time the process started.

    It clearly mentions DISK, so these are hard page faults which makes my article valid.

    To get crash dump reports, you can set the page file to a minimum size of 2MB (mini crash dumps require just 64KB for 32 bit systems and 128KB for 64 bit). I have already mentioned some applications refuse to load without a page file so setting the page file to a small value will fix this problem and at the same time minimize page faults.

    ReplyDelete
  5. DH is correct, Task Manager shows both soft and hard page faults. In most cases the majority will be soft page faults that do not touch the disk. The Microsoft article referenced is wrong.

    Even in the case of hard page faults, the majority do not involve the pagefile. Task Manager and even Performance Monitor will not tell you which ones do. Paging occurs with a wide variety of files, not just the pagefile. In fact, most disk IO operations are done with paging. Launching an application and even loading a text file into an editor will be done with paging.

    Disabling the pagefile will not reduce these other forms of paging. Only modified data will be written to the pagefile. When an executable file or DLL is unloaded it is not written to the pagefile as it can simply be reloaded from the original file. With no pagefile all modified data must remain in RAM, even if it has not been accessed for a long time, even if it will never be accessed again. This can put a heavy strain on the RAM resources of a system.

    Do not be misled by the high "Available" memory as shown in Task Manager. The majority of this is not free. In a virtual memory system, memory being both available and in use is not a contradiction.

    The most accurate source of information regarding Windows internals is the publication "Inside Microsoft Windows". This is heavy reading. Articles intended for a general audience often oversimplify things and occasionally make outright mistakes.

    Larry Miller
    Microsoft MCSA

    ReplyDelete
  6. Thanks for the information Larry.

    ReplyDelete
  7. My comment is on home systems, not servers. Due to the complexity and demands on business and enterprise servers, they should always have a page file(s)

    With home systems now using (or starting to use) 64bit OSes and 8, 16, or 32GB of RAM. IMO the need for a paging file on these systems is almost 0.

    RAM is getting cheaper. In fact it's getting cheaper faster than people can write programs to use it. A 32bit app can address no more than 2G of ram anyway. 64 bit apps have a huge address range, but most hope apps for a while won't try to go over 4GB

    The only real danger in disabling the page file system is this:
    Some apps when they load, "reserve" a vast memory pool to make sure they don't run out. If you lack the physical ram, the app will fail. Typically with a page file, when an app does this, Windows will quickly swap it to disk until it's needed. In this case, if you dont have a pagefile, the app will perform better, however, that unused ram will sit idle doing nothing, but if you have 8,16,or 32GB of ram, it might not be a big deal.

    In some RARE cases, an app actually LOOKS for the pagefile, and fails if none is present (BAD PROGRAMMING)

    Disabling the page file will NOT cause a modern version of Windows to fail to boot unless you are trying to boot up with less ram than the OS needs.

    If you disable the pagefile system, the OS DOES have safegaurds. For example, even if you set it no NO page file, and all the physical ram runs out, widows will "freeze" for a few seconds while it makes a temporary, emergency page file. Then it will usually give you a pop up down by the system clock that's it's done so. However, this is an ugly process and sometimes crashes the OS, if you see this happening, then you NEED a pagefile.

    A "compromise" to the argument is to enhance the pagefile. For example:

    If you have more than 1 physical drive, make 2, 3, or 4 page files (1 for each driver). Windows will then use the pagefile on the disk that is being use the LEAST. Windows can also use multiple page files AT ONCE. So by splitting them up, you sort of make a "raid pagefile." IMO this really is THE most optimal way to handle the pagefile unless you have a DEDICATED, physical disk to it, and HDs under 80GB are hard to come by, and a waste to make just as a page drive.

    Also putting the paging file on a RAID drive will help also. If you only have one local drive, C:, then you have no choice, but if you have a system that boots with 1 physical drive (non raid) and has a second drive as an array, the main page file should go there, and only JUST enough of a pagefile on C: for either a partial or full crash dump. I recommend PARTIAL as dumps on systems with 8, 16, or 32GB of ram can take QUITE a long time.

    In most of the above cases, when more than 1 physical drive is available, C: should only have a page file large enough to handle a partial or full crash dump. This will prevent the OS grinding the pagefile on the drive the OS runs on - thus vastly improving the boot time of the OS, logging in, and doing various other things while the OS is running.

    David Dutton
    Microsoft MCSE (15 yrs)

    ReplyDelete
  8. I'm going to side with OP. I've been using windows since the days of windows 286 / 386. I noticed very early on that windows used physical memory to administer the swapfile.

    e.g. 4Mb RAM + 8Mb pagefile = 11Mb free after loading.
    4Mb RAM + 2Mb pagefile = 4Mb free after loading.

    I'm probably well out of date, but I've long since given up upgrading for the sake of it. I have W2k on a PIII 1Ghz. It has 1Gb RAM - 1 disabled the pagefile ages ago.

    Just sayin'.

    ReplyDelete
  9. I'm about to upgrade my memory to 8 gigs, it seems to me after a lot of reading and a bit of playing around that if I use Ramdisk utility to make another hard drive in the Ram this would be the best page file.
    My system runs very fast with 4 gig 1333mhz and 6gig page on the hard drive now. So if I had a 3 or 4 gig page in the ram running at the new rams 1600mhz, the speed over a hard drive should offset the slightly smaller size.
    Also less wear and fragmentation, I'll stick a few megs of page file on drive C as advised by the man from Microsoft also.

    ReplyDelete
  10. As a C++ software developer, I don't have to code page file use of memory as it is handled by C allocation functions and the OS automatically. I don't understand why we can't "turn off" both soft and hard page faults when there is 32gb in a desktop system and let applications keep their memory without paging them at all at least on an application by application basis if not the entire system. I find it irritating to see firefox idling do 3000 soft page faults per second. Of course I started programming in CP/M with 48k of ram and never had these silly performance issues back then. I didn't have to deal with spyware either as there was no internet.

    ReplyDelete
  11. Page file made my hard drive make a parking pinging noise every 2 minutes.
    Maybe it's my drive but the noise is gone with no page file.

    My question is that Win 7 has readyboost option. I use a 8GB USB Flash Drive for readyboost. Can I somehow set the page file to only use that? That makes the most sense to me as it is a cheap part and fast too. This would free up the Ram and lengthen HD life.

    ReplyDelete

Popular Posts