The Truth About Virtual Memory

July 11th, 2007
1 Star2 Stars3 Stars4 Stars5 Stars (6 votes, average: 5 out of 5)
Loading ... Loading ...

Okay, class, today we’re going to talk about virtual memory. I’ve chosen this topic because there are quite a number of inaccuracies in common circulation. Here are a few false beliefs about virtual memory.

  1. More is better.
  2. There is a set rule for determining how much you need.
  3. Setting a static swap file size will make virtual memory more effective.
  4. Emptying the Pagefile will increase system performance.
  5. You can eliminate the page file if you have enough physical RAM installed.

All of these are false!!!!

I’m going to give you a brief overview of Virtual Memory, destroy these myths, and give you some good advice about how to manage it. So let’s begin.

Virtual Memory is Windows’ name for a swap file. It allocates a portion of your hard drive space for use by your system RAM. As programs run on your PC they load instructions into RAM. These instructions are then passed to the processor. The more active programs are running, the more RAM your system requires. Very often this amount is more than your physical RAM has available so some of the information is unloaded to the page file.

Windows makes an effort to keep memory full at all times. So often programs that have been closed still reside in memory. This is by design. That’s why the use of RAM cleaner programs will typically decrease system performance rather than improving it. When programs are unloaded to the page file, the oldest least used ones go first. When you’re running enough programs that active ones are moved to the page file, this is when your computer bogs down. It slows down because the swap file is only as fast as your drive seek speed and your IDE transfer which are much slower than the FSB transfer speed that your RAM uses.

The NT kernel is designed to use virtual memory. Period. Never eliminate the page file by setting your virtual memory to zero. You only hurt your performance. So the big question now is:

How much virtual memory do you need?

The answer is - that depends on what you’re doing. At minimum, you want to have the amount of physical RAM plus about 512MB. Having too little forces your system to completely unload information it needs just to have to load it into memory again later, and having too much forces your computer to attempt to fill it pointlessly. That’s why there can’t be a rule of thumb on how much you need. It’s different for every system and every user.

Pages: 1 2

Please use the trackback link when linking to this post.

Related Posts:

Add to Technorati Favorites

6 Responses to “The Truth About Virtual Memory”

  1. Tony Says:

    Awesome entry! This is one of the most controversial topics.

    It is quite amazing to read all of the myths debunked and the whole Virtual Memory phenomenon demystified.

    Thanks,
    Tony

  2. anjanesh Says:

    Having too little forces your system to completely unload information it needs just to have to load it into memory again later
    Assuming 2GB of physical RAM, why would it force to unload when it can keep residing in the physical memory even when 1GB of physical memory is still available ?

    If your peak is less than your installed RAM, then set your minimum to your installed RAM + 512MB.
    Assuming 2GB of physical RAM, does this mean that we need to set the Paging-file-size to 512MB or 2.5GB ?

    Creating a dedicated partition for your page file will also improve its performance dramatically
    How is it possible to set C:’s page-file to say, X: ? By default, C:’s page-file resides in C:\Windows

  3. Nilpo Says:

    Hi anjanesh,

    Thanks for the reply. You can change the location of the paging file from the within the System Properties control panel applet. Details can be found in the following knowledgebase article.

    http://support.microsoft.com/kb/307886

  4. anjanesh Says:

    Will there be a seek-time-delay if the partition to where I change the paging-file location is on another hard-disk ? (but a better one - SATA2)

  5. Nilpo Says:

    Moving the paging file to another drive or partition that is accessed less frequently than the boot partition will provide noticeable improvements. Since your secondary drive will be accessed much less, the seek time should improve over that of your primary drive–and the fact that your secondary drive is faster will be an added bonus.

  6. Larry Miller Says:

    The author does a good job of dispelling a number of myths. Unfortunately he injects a number of new myths and inaccuracies.

    First, there are the persistent references to the pagefile as virtual memory. Not only is this incorrect but it also encourages further misunderstandings. The pagefile is an important part of the virtual memory system but it is only a part. Only modified data will be written to the pagefile, not program code.

    The default setting of letting Windows manage the pagefile is best for most users. If you have little RAM you may have to raise the lower value to avoid warnings. There is no need or value in restricting the upper limit, except that the Win32 platform does not support a single pagefile over 4GB.

    There is no value in clearing the pagefile at shutdown except for security purposes. Windows will not permit this during a session.

    Larry Miller
    Microsoft MCSA

Leave a Reply