Virtual memory is a feature of an operating system that enables a process to use a memory (RAM) address space that is independent of other processes running in the same system, and use a space that is larger than the actual amount of RAM present, temporarily relegating some contents from RAM to a disk, with little or no overhead.
In a system using virtual memory, the physical memory is divided into equally-sized pages. The memory addressed by a process is also divided into logical pages of the same size. When a process references a memory address, the memory manager fetches from disk the page that includes the referenced address, and places it in a vacant physical page in the RAM. Subsequent references within that logical page are routed to the physical page. When the process references an address from another logical page, it too is fetched into a vacant physical page and becomes the target of subsequent similar references.
If the system does not have a free physical page, the memory manager swaps out a logical page
into the swap area - usually a paging file on disk (in Windows
XP: pagefile.sys), and copies (swaps in) the requested logical page into the now-vacant physical page. The page swapped out may belong to a different process. There are many strategies for choosing which page is to be swapped out. (One is LRU: the Least Recently Used page is swapped out.) If a page is swapped out and then is referenced, it is swapped back in, from the swap area, at the expense of another page.
Virtual memory enables each process to act as if it has the whole memory space to itself, since the addresses that it uses to reference memory are translated by the virtual memory mechanism into different addresses in physical memory. This allows different processes to use the same memory addresses - the memory manager will translate references to the same memory address by two different processes into different physical addresses. One process generally has no way of accessing the memory of another process. A process may use an address space larger than the available physical memory, and each reference to an address will be translated into an existing physical address. The bound on the amount of memory that a process may actually address is the size of the swap area, which may be smaller than the addressable space. (A process can have an address space of 4GB yet actually use only 2GB, and this can run on a machine with a pagefile of 2GB.)
The size of the virtual memory on a system is smaller than the sum of the physical RAM and the swap area, since pages that are swapped in are not erased from the swap area, and so take up two pages of the sum of sizes.
Usually under Windows, the size of the swap area is 1.5 times the size of the RAM.
The virtual memory manager might issue the message:
"Your system is low on virtual memory. Windows is increasing the size of your virtual memory paging file." This happens if it is required to swap out a page from RAM to the pagefile while all pages in the pagefile are already taken. With that message, it will allocate more space to the pagefile and use the added space to store the newly- swapped-out page (and subsequent pages).
One case that might cause the system to want to enlarge the pagefile is that too many processes are running. In this case, only relatively little of each process' memory can fit in the RAM, and relatively many pages reside in the pagefile. In this case, the virtual memory system is required to hold too many pages - a "small" number of pages per process times "many" processes. In such a case it is also likely that the system will run slowly, since pages need to be swapped in and out more frequently.
Another case that might cause the system to want to enlarge the pagefile is that a process has a memory leak. There, the process is occupying a lot of unused memory, which will likely be swapped away in the pagefile and never be swapped in.
The usage of the pagefile in Windows can be seen in the Task Manager by checking the Virtual Memory Size box after View, Select Columns.
The pagefile can be fragmented, and tools exist to defrag it.
Microsoft explains how to increase the size
of the pagefile.
What should you do if you get this message? "Your system is low on virtual memory. Windows is increasing the size of your virtual memory paging file."
Sysinternals offers a pagefile defragmenter.