The Windows paging file, also known as the swap file or virtual memory, is very important to the operation of Windows Vista. As I mentioned earlier, the operating system uses the paging file as a place to store data that was once in physical memory but was kicked out because Windows needed the space for other purposes.
Every ounce of data that the CPU works with has to be in physical memory before any work can be done. When you start an application, Windows loads the program from the hard drive into physical memory so the CPU can execute the code. Because most computers have a limited amount of physical memory (RAM), Windows has a complex paging system that allows applications that are running to be temporarily moved out of physical memory to make way for other applications. This data that was in memory is stored back into a file on the hard drive called the paging file.
Providing a critical memory feature by allowing the operating system to use more random access memory (RAM) than the computer actually has allows users to use more robust programs without upgrading their memory.
The exact method that the system uses to decide what programs will stay in the physical RAM and what programs will go is very complex and next to impossible to alter. However, there are several paging file hacks that will help you optimize your computer's use of the paging file. With the help of hacks to the system Registry, you can prevent certain files from being pushed into the paging as well as completely disabling the paging file to prevent the entire system from using it.
This next section guides you though the steps of optimizing the paging file for your computer.
If you have a large amount of RAM in your box, you have the ability to stop the operating system from pushing any data out into the paging file. This will cause faster memory management and memory access than is physically possible for your RAM. Reading and writing directly to the RAM is always significantly faster than having to use the page file. Reading and writing to the paging file requires multiple steps and that takes time. First the data has to be copied out of physical RAM to the hard drive, and then the new data must be loaded from the hard drive into RAM and then executed. The hard drive is a big bottleneck in this situation.
If you have more than 2GB of RAM in your computer, you can consider disabling the paging file. If you have less than 2GB of RAM, do not even consider disabling the paging file or you will be running into problems.
What can happen if you disable your paging file? If you have enough RAM, nothing. But if you do not have enough RAM, your applications may refuse to load or even crash. For example, if you run Photoshop and are working on a large image, you will run into "out of memory" errors and the application will crash, causing you to lose all your work. This is a pretty extreme example, but it can happen to you if you don't have enough RAM.
Basically, stick to the 2GB minimum and you will have no problems. But be aware that if you ever choose to run some memory-intensive applications, such as rendering a two-hour 3D movie, you could run out of memory easily.
So, now that you know the concerns, you are ready to follow these steps to disable the paging file:
Click the Start button, right-click Computer, and select Properties.
When System has loaded, click Advanced system settings, as shown in Figure 12-4.
Figure 12-4: Selecting Advanced system settings
Under the Performance section, click Settings.
Click the Advanced tab and then press Change under Virtual memory.
This will load the Virtual Memory screen. Uncheck the box that says Automatically manage the paging file size for all drives.
For each drive listed in the box that has a paging file configured on it, select the No paging file option and press Set, as shown in Figure 12-5.
Figure 12-5: Using No paging file in Windows Vista
After you have gone through the list and verified that you no longer have any paging files configured on your drives, click OK to exit.
Your paging file will now be disabled after your reboot. Feel free to delete the pagefile.sys file from your hard drive after your reboot to gain a few hundred megabytes of free space.
If you do not have enough RAM to disable the paging file completely, follow the directions in the next section to adjust the size of the paging file for best performance.
The size of the page file can be set automatically by the system or it can be set by the user. In some situations, having the page file managed by the system is a good idea, but in others, it is better to manage the paging file yourself.
The biggest argument for setting the paging file size and limit manually is to eliminate growing of the page file when it is set by the system. When the system is managing the size of the paging file, it will monitor the size of the file and will then automatically make it larger when it is needed. This causes two problems. First, it will cause a noticeable delay for all applications running on your computer because the computer has to expand the paging file and this is a hard disk-intensive operation. Second, allowing the system to grow and shrink the paging file causes fragmentation errors.
For the sake of having enough speed, your page file should not have any file fragments. In the next section on defragmenting you will learn exactly how to fix this. But before the defragmentation can be successful, the page file needs to have a constant size. If the page file will be growing frequently, and because the defrag utility has no clue by how much, the defrag utility cannot put the file in a place on the hard disk so that it will never get fragmented, as is the case when you set the page file manually to a constant size.
Setting the paging file to a constant size does have some disadvantages. For example, the lost disk space taken up by the paging file can be as high as 5GB. Additionally, when you set the maximum paging file size manually, you are setting a limit that your computer can never go above. Should you run an extremely memory-intensive application and your limit is too low, your paging file will fill up and you will be out of luck in much the same way as when you completely disable your paging file.
The previous example illustrates why setting the correct paging file size is so important. An easy way to calculate the maximum size of your page file is to take the recommended size of the page file from the Virtual Memory Settings window, as shown in Figure 12-6, and multiply it by 2. If you are having problems finding where your computer states the recommended size, perform the following steps to change the paging file to a constant size because this value is on the same screen as the one on which you will be working.
Figure 12-6: Virtual Memory settings showing the recommended paging file size
Now that you are ready to optimize the paging file to a constant size, follow these steps:
Click the Start button, right-click Computer, and select Properties.
When System has loaded, click Advanced system settings.
Under the Performance section, click Settings.
Click the Advanced tab and then press Change under the Virtual memory section.
This brings up all the page file settings. Modify the custom values so that the initial and maximum sizes are the same. To do this, you first need to enable the option to set a custom size, so select the Custom size option.
Enter the value that you calculated in these two boxes, as shown in Figure 12-7.
Figure 12-7: Setting the paging file to a custom size
Click the Set button and then click OK to exit.
After you restart, you will be using the new constant size paging file. You are now ready to run your defragmenter to defragment the paging file to ensure optimal performance.
Caution | The method that I use to calculate the size of the constant paging file is a very conservative and effective approach. However, if you feel the need for more free disk space, feel free to play around with the calculation, such as multiplying the recommended amount by only 1.75 or maybe even 1.5. Although if you do that, keep in mind that you will be increasing your chances of maxing out your paging file. |
The paging file can be placed on any storage device in your computer. If you really wanted to, you can even move the paging file to an external hard drive connected over USB. Although this would probably slow down your system because an external hard drive is often slower than a hard drive connected inside your case, it is still possible. However, if you have multiple hard drives in your system, and I am not talking about multiple partitions on the same drive, you may see a performance increase if you move your paging file off the main system drive.
Moving the paging file off your main drive will allow it to be accessed faster in situations in which your primary hard drive is busy. When users add hard drives to their computers, these new hard drives are typically faster than the hard drives that the computers came with because of advances in technology over time. Moving your paging file to the faster hard drive will also help performance.
Changing the location of the paging file is very easy. Just follow these steps and you will have it done in no time:
Click the Start button, right-click Computer, and select Properties.
When System has loaded, click Advanced system settings.
Under the Performance section, click Settings.
Click the Advanced tab and then press Change under the Virtual memory section.
Now that you have the Virtual Memory settings displayed, select the drive on which your current paging file is located from the list of drives.
Before you make any changes, write down what the initial and maximum size text boxes contain. Then, click the No paging file option and press the Set button.
Select the hard drive on which you want your new paging file to be placed from the list of drives.
When the new hard drive is highlighted, select the Custom Size option and enter in the numbers that you wrote down before. If you are not using the Custom Size mode, click the System Managed Size mode but reconsider what was talked about in the last section because it will help your performance.
Click the Set button, click OK, and you are finished.
After a reboot, your system will be using the paging file on the new hard drive. Feel free to delete pagefile.sys from your old hard drive location; it no longer is needed there.