Virtual Memory Optimization in Windows Computers
What is Page File?
A key to improving your PC’s performance is the page file (also called the swap file and/or virtual memory). A page file is a cache of data on your hard drive; this cache is used to supplement your computer’s main memory (RAM). When a computer runs out of memory, it uses the page file. Since data access on a hard drive is slow compared to accessing memory, your PC’s performance takes a hit.
What is exactly Virtual Memory?
In a 32-bit computer, the memory addresses are 32 bits long and stored as binary (base 2) numbers. There are approximately 4 billion possible different 32-bit binary numbers (2^32=4,294,967,296). Because of this, there is a 4GB limit for addressable memory in a 32-bit computer.
A program instruction on an Intel 386 or later CPU can address up to 4GB of memory, using its full 32 bits. Each process is assigned an address space of 4GB of virtual memory, regardless of the amount of available physical memory. Each process is isolated from the rest and has its own 4GB address space. This means that the 4GB addressability limit applies on a per-application basis, not across all applications taken together.
This is normally far more than the RAM of the machine. The amount of physical memory on the computer is not related to the amount of memory address space. If a computer has 256MB of physical memory, there is still a 4GB memory address space, and if a computer has 8GB of physical memory, there is still a 4GB memory address space.
Applications are not allowed direct access to physical memory. When an application requests more memory, Windows maps some physical memory (as long as some is available) into the process’s address space.
The hardware provides for programs to operate in terms of as much as they wish of this full 4GB space as Virtual Memory, those parts of the program and data which are currently active being loaded into Physical Random Access Memory (RAM). Windows maintains several tables that keep track of all of this, and the application knows only about the virtual memory address.
The processor itself then translates (‘maps’) the virtual addresses from an instruction into the correct physical equivalents, doing this on the fly as the instruction is executed. The processor manages the mapping in terms of pages of 4KB each - a size that has implications for managing virtual memory by the system.
Why do I need page file optimization?
Optimizing your page file when you’re running low on RAM is always a good idea. When all physical RAM in a computer is in use, Windows starts using the hard disk as if it were additional RAM. This is why we have a Page file (also called the swap file). Because RAM memory is a lot faster than the hard disk, whenever the computer begins to use the Page file to relieve memory pressure, we begin to experience drastic performance degradation.
One of the most effective things you can do to improve performance is ensure that there is enough RAM available to avoid frequent paging (swapping) of memory contents between disk and RAM.
This means that the actual limit on the memory used by all applications is the amount of RAM installed plus the maximum size of the Page file.
How much swap space do you need? That depends the amount of RAM you have and the programs you use. The current algorithm Windows uses to set the default paging file size is:
- If total physical RAM is less than 2 gigabytes (GB), the paging file is set to 1.5 times the amount of RAM or 2 GB, whichever is smaller.
- If total physical RAM is equal to or more than 2 GB, the default size is set to 2 GB.
Should You Disable Your Page File?
Several experts suggest that you disable the page file to increase performance, by doing away with the page file that means your computer won’t have to access the hard drive. So it should be faster, right? It can be, or it can cause several instability problems for your computer. Many programs won’t even run without a page file enabled. The effect definitely depends on the amount of physical memory available. The 8 GB RAM systems might run just like normal, but when you lower the amount of memory available to 2 GB, system instability will definitely be visible.
Page File configuration
For simplicity of the task, you might follow the Microsoft recommendations listed above for the amount of the Page file settings. However, you can go further and set it according to particular needs of your computer, which require more time and more experience.
Open System Properties, then the Advanced tab and press the Performance Settings button, selecting the Advanced tab, finally pressing the Change button. Select the Drive which XP is installed to and set the Paging file size for selected drive to Custom size, setting the Initial size and Maximum to 1500MB according to the basic recommendations. If you have multiple drives available ensure these are set to No paging file. Click Ok and restart as required for the changes to take effect.
You can stop right here if you do not want to go deeper and you are satisfied with standard settings. Otherwise, you can continue with recommendations below.
After computer reboot press Ctrl + Alt +Delete simultaneously and load the Task Manager, selecting the Performance tab. This tab allows use to monitor peak Virtual Memory use (The Peak value in the Commit Charge (K) section). This window can be minimized and you should then run your most resource intensive Applications in order to see just how Virtual Memory is utilized. Once you’re satisfied with your testing switch back to Task Manager.
Once more open System Properties, select the Advanced tab and press the Performance Settings button, selecting the Advanced tab, finally pressing the Change button.
A few general points to recall before you do anything;
If you have only 1 Hard Drive, split into multiple partitions, the Page File should be set to the partition XP is installed to, you should not create multiple Page Files for different partitions in this case, i.e. 1 Hard Drive = 1 Page File.
If you have multiple Hard Drives installed it is beneficial to locate the Page File on the Hard Drive XP is not installed to; but only where the other Hard Drive is of a similar or better performance, e.g. if you have a SATA Drive and ATA 100 Drive the Page File should be located on the SATA Drive regardless as it is notably faster.
The Page File should not be located on a mirrored Drive, e.g. RAID array, if possible as fault tolerance/backup is not required and may decrease performance.
How to overcome the 4GB limitation for page file in Windows?
When you set the paging file size in Windows, the documentation states that the largest paging file that you can select is 4,095 megabytes (MB). This limit is imposed by the page mapping that we use on x86 processors. These processors cannot handle more pages per page file. This is the limit set per volume; you can actually create paging files this large on one or more drives if you need a larger paging file. If extra drives or volumes are not available, you can create multiple paging files on a single drive by placing them in separate folders.
To create multiple paging files on one volume to overcome the 4,095-MB limit:
1. On the drive or volume you want to hold the paging files, create folders for the number of paging files you want to create on the volume. For example, C:’Pagefile1, C:’Pagefile2, and C:’Pagefile3.
2. Click Start, Click Run, type regedit in the Open box, and then click OK.
3. In the left pane, locate and click the following registry subkey:
HKEY_LOCAL_MACHINE’System’CurrentControlSet’Control’SessionManager’MemoryManagement
4. Find the Pagingfiles value, and then double-click it to open it.
5. Remove any existing values, and add the following values:
c:’pagefile1’pagefile.sys 3000 4000 c:’pagefile2’pagefile.sys 3000 4000 c:’pagefile3’Pagefile.sys 3000 4000
6. Click OK, and then quit Registry Editor.
7. Restart the computer to cause the changes to take effect.
8. Access the virtual memory settings to check the properties of the paging file. To do this, follow these steps.
Sources and Additional Information:
http://www.petri.co.il/pagefile_optimization.htm
http://g4tv.com/techtvvault/features/36099/Optimize-Windows-XP-Page-File.html
http://support.microsoft.com/kb/237740
http://www.pctipsbox.com/speed-up-windows-by-optimizing-your-page-file/
http://www.techspot.com/tweaks/memory-winxp/memory-4.shtml