Virtual Memory Definition

Virtual memory is the use of space on a hard disk drive (HDD) to simulate additional main memory.

Memory is used to hold portions of the operating system, programs and data that are currently in use or that are frequently used. Physically, main memory (also referred to as primary memory) consists of random access memory (RAM) chips that are combined into modules which, in turn, are inserted into slots on the motherboard (i.e., the main circuit board) on a computer. The times required to access different addresses (i.e., locations) in RAM are extremely short and nearly equal, in contrast to the varying delay times for accessing locations on the HDD and other storage devices.

In order to free up space in memory, an operating system with a virtual memory capability transfers data that is not immediately needed from memory to the HDD; when that data is needed again, it is copied back into memory. That is, when all of the RAM is being used (e.g., if there are many programs open simultaneously or if one very large program is in use), a computer with virtual memory enabled will swap data to the HDD and back to memory as needed, thus, in effect, increasing the total system memory.

Virtual memory permits software to run in a memory space (i.e., a logical memory) whose size is greater than the computer's RAM. Most personal computers sold today contain from 256MB to 1024MB of RAM. While this is huge in comparison to what was common just a few years ago, it is still often insufficient to simultaneously run all of the programs that users attempt to run. The reason is that the size of many programs has continued to increase accompanying the growth in memory sizes and HDD capacities, largely in order to add more features (including fancier graphics).

Application programs cannot distinguish between primary memory and virtual memory, and thus they run as if all the data is in primary memory. Virtual memory is likewise usually invisible to the user. However, its existence can become apparent in the form of degraded performance if it is used too heavily, because the CPU (central processing unit) will spend more of its time copying data back and forth to the HDD and less of its time doing useful work. This is termed thrashing. The reduced efficiency is also a result of the facts that HDDs are far slower than RAM and that they are not designed for accessing small pieces of data (e.g., single bytes) one at a time.

Virtual memory has become a standard feature of most operating systems on desktop and notebook computers. This is because it provides a large benefit to users at a very low cost. That is, the cost of hard disk space is only a small fraction of that of an equal amount of RAM, and thus it pays to install, and use, more of the former and less of the latter.

The space on a HDD that is used to store the overflow from memory is called swap space. On Linux it is a separate partition (i.e., a logically independent section of a HDD) that is set up during installation of the operating system and which is referred to as the swap partition. It is generally recommended that the size of the swap partition be about twice the amount of system RAM.

The swap space is divided into segments called pages, each of which is associated with a specific address in memory. When an address is referenced, the page is swapped into memory. It is returned to the disk when no longer needed and other pages are called. This management of virtual memory is performed by a type of hardware circuitry called a memory management unit (MMU).

Most CPUs now include built-in MMU circuitry, which improves performance as compared with separate MMU chips. In order to facilitate this switching, CPUs also maintain a table of recently used main-to-virtual memory translations, called a translation lookaside buffer (TLB).

The origin of virtual memory is not entirely clear. It was apparently first employed at the University of Manchester in the UK for the Atlas Computer, which was completed in 1962. However, Fritz-Rudolf Güntsch, a German computer scientist who developed the Telefunken TR 440 mainframe, claims to have first proposed the concept in his doctoral dissertation in 1957. Virtual memory was incorporated into the UNIX kernel (i.e., the core of the operating system) in the 1970s as part of the Berkeley Extensions, which were developed at the University of California at Berkeley (UCB).

Virtual memory is so important that its acronym, i.e., vm, was incorporated into the name of the Linux kernel as it is used on most systems, i.e., vmlinux for the non-compressed version and vmlinuz for the compressed, bootable (i.e., runnable) version.

Created June 21, 2004. Updated October 6, 2005.
Copyright © 2004 - 2005 The Linux Information Project. All Rights Reserved.