What's the difference between virtual memory and real memory? And how can I add more virtual memory to my computer?
What is Virtual Memory?
There's a lot of talk about all things virtual these days: virtual servers, virtual storage, virtual desktops, and so on. Memory can be virtualized as well. So what is virtual memory? When all the programs running on your computer consume the real physical memory (RAM) on your motherboard, your operating system will grab a chunk of unused hard drive space and create virtual memory. Your software can't tell the difference between real memory and virtual memory. The only practical difference is that RAM (real memory) has a much faster access time than a hard drive (virtual memory).
Why is virtual memory useful? Well, unlike physical memory, virtual memory is free and relatively unlimited, as long as you have a few gigabytes of free space on your hard drive. It's a very efficient way to extend the capacity of physical memory. Even though virtual memory is not as fast as real memory, it's better for your computer to manage virtual memory behind the scenes than to say "Sorry, memory is full. Please close one program before opening another."
So how much virtual memory is on your system? The general rule of thumb, at least on Windows-based computers, is for virtual memory to be about 1.5 times the size of the physical memory. But, the more physical memory you have the less virtual memory will need to be used. Here's an example: Let's say you have 2 GB of RAM, and after booting up your computer, and opening your browser and email program, the amount of real memory in use is only 1.8 GB. Your computer will not be using any virtual memory at that point. But suppose you then launch your video editing program and open up a couple of high-res video clips. Now your computer needs 3.4 GB of memory to keep all the balls in the air, so 2 GB of real memory, plus 1.4 GB of virtual memory will be required. If you kept all those programs open and then launched another memory-hungry application, you might approach the combined amount of real plus virtual memory that's available. Only at that point would you see an "Out of Memory" or "Low Virtual Memory" message from your computer.
Increasing Virtual Memory
If you find that you're taxing your memory to the limits, there are ways to increase the amount of virtual memory available. In Windows, virtual memory is known as a pagefile, or more specifically, the file named pagefile.sys. Virtual memory settings can be tweaked within the operating system. In Windows XP, go into the Control Panel, then System, and click the "Advanced" tab. Click on the "Settings" button under the "Performance" heading. Then click on the "Advanced" tab under "Performance Options". Under the "Virtual Memory" heading, you'll see the "total paging size" listed -- this is the amount of virtual memory currently available. Click on the "Change" button to modify your virtual memory settings.
In the above example, the system has 2046 MB of virtual memory at startup (the initial size) and will expand to a maximum of 4096 MB. You have three choices for configuring your virtual memory. The simplest is to select "System managed size" and just let Windows control the amount of virtual memory as it sees fit. You can also select "Custom size" and enter your own initial and maximum size values. My recommendation is to set both values at 1.5 or 2 times the amount of real memory. So if you have 2 GB of RAM, you might enter 3072 for the initial and 4096 for the maximum size. (Remember that 1000 MB is one gigabyte.) Your third option is to select the "No paging file" option. Do this only if you have lots of RAM, and you're sure that you'll never need to use virtual memory.
You can customize the pagefile the same way in Vista. However, Vista has an even better way to increase virtual memory. ReadyBoost is a new technology in Vista that uses flash memory to increase system performance. Plus, it's easy to use. Simply connect a USB 2.0 flash drive to your machine. An AutoPlay windows will pop up, showing that Vista sees a Removable disk has been added to the system. Click on the "Speed up my system" option. Select the "Use this device" option when the ReadyBoost configuration page opens. Adjust the slider to set the amount of space you want to use. See the companion article Vista ReadyBoost for more information.
Virtual Memory Efficiency
Technology professionals (read: geeks like me) will sometimes recommend that you move the pagefile.sys file to a separate disk from the one on which Windows is installed. The idea is that your multi-tasking operating system may be able to access the virtual memory faster if it's on a dedicated hard drive that's not busy doing stuff with programs or files. It may also reduce pagefile fragmentation, which will improve the efficiency of reading and writing virtual memory on the disk. Note that moving it to another partition on the same drive will not make a difference. To have any impact, the pagefile should be moved to a separate physical hard drive. To move your pagefile, use the Virtual Memory settings dialog discussed earlier. Select the drive where you want your pagefile to reside, and set the initial and maximum sizes as desired. Then select the C: drive, and change the initial and maximum sizes to 126MB. (You can make it smaller, or even choose the "No Paging" option, but the system will not be able to create a log file if a system failure occurs.) You'll have to restart your system for the changes to take effect.
Mac OS X can also be tweaked to optimize virtual memory. The best way to do this, is maximize the amount of physical RAM in the system. Mac OS X can efficiently handle the allocation of virtual memory without too much user interference, provided there is a sufficient amount of physical memory. The "swap" file is the Mac OS X equivalent of the pagefile in Windows. The swap file can also be moved to a different drive in Mac OS X. See this Mac OS X Hints article for details.
Running Linux? One of the advanced setup options when installing Linux is where to put the swap file. You can also change the location of your Linux swap file. See this nixCraft article for help with that.
Of course, not using virtual memory at all (or as little as possible) would be the most efficient option. And to do that, you'll need to install the maximum amount of physical memory that your system can handle. See Adding Memory for information on finding out how much RAM you have, and how to add more.
Your input is welcome! Post your comments and questions below...
This article was posted by Bob Rankin on 15 Dec 2008
|For Fun: Buy Bob a Snickers.|
Watch Television on Your Computer
The Top Twenty
Free Registry Cleaners
Post your Comments, Questions or Suggestions
Free Tech Support -- Ask Bob Rankin
Subscribe to AskBobRankin Updates: Free Newsletter
Copyright © 2005
- Bob Rankin - All Rights Reserved
Article information: AskBobRankin -- Virtual Memory (Posted: 15 Dec 2008)
Copyright © 2005 - Bob Rankin - All Rights Reserved