Encyclopedia  |   World Factbook  |   World Flags  |   Reference Tables  |   List of Lists     
   Academic Disciplines  |   Historical Timeline  |   Themed Timelines  |   Biographies  |   How-Tos     
Sponsor by The Tattoo Collection
Virtual memory
Main Page | See live article | Alphabetical index

Virtual memory

Virtual memory is a computer design feature that permits software to use more memory than the computer physically possesses. In technical terms, it allows software to run in a memory address space whose size and addressing are not necessarily tied to the computer's physical memory. It is often a feature of a computer's operating system and may or may not be a feature of the computer's hardware.

Table of contents
1 History
2 Explanation
3 Windows example
4 See also
5 External links


The technique was invented at the University of Manchester for the Atlas Computer, completed in 1962. It might be worth a note though that Fritz-Rudolf Güntsch, one of Germany's pioneering computer scientists and later the developer of the Telefunken TR 440 mainframe, claims to have invented the concept in his doctoral dissertation Logischer Entwurf eines digitalen Rechengerätes mit mehreren asynchron laufenden Trommeln und automatischem Schnellspeicherbetrieb (Logic Concept of a Digital Computing Device with Multiple Asynchronous Drum Storage and Automatic Fast Memory Mode) in 1957.


Simply put, when a memory location is read or written to, hardware within the computer translates the memory address generated by the software (the virtual memory address) into a, usually distinct, real memory address (the physical memory address) within the computer's memory. This is accomplished by preserving the low order bits of the binary representation of the input address while treating the high order bits as a key to one or more address translation tables. For this reason a range of consecutive addresses in the virtual address space whose size is a power of two will be translated in a corresponding range of consecutive physical addresses. The memory referenced by such a range is called a page. The page size is typically in the range of 512 to 8192 bytes (with 4K being very common), though page sizes of 4 megabytes or larger may be used for special purposes. Using the same or a related mechanism, contiguous regions of virtual memory larger than a page are often mappable to contiguous physical memory for purposes other than virtualization, such as setting access and cache control bits.

The translation is implemented by an MMU. This may be either a module of the CPU or an auxiliary, closely coupled chip. The MMU may have the ability to monitor page references according to the type of reference (for read, write or execution) and the privilege mode of the CPU at the time the reference was generated. In addition, the MMU may detect that a reference is to a page that is marked as unavailable. The MMU responds to such conditions by raising an exception with the CPU which will be trapped by system software. This makes it possible for an operating system to carry out swapping. This is the behaviour of copying one page of memory to disk in order to restore to memory another page copied to disk earlier. This can be realized in a swap partition, a dedicated section of disk in order to hold paged memory, or in a swap file.

To minimize the performance penalty of address translation, most modern CPUs include an on-chip MMU, and maintain a table of recently used physical-to-virtual translations, called a Translation Lookaside Buffer, or TLB. Addresses with entries in the TLB require no additional time to translate.

The most fundamental advantage of virtual memory is that it allows a computer to multiplex its CPU and memory between multiple programs without the need to perform expensive copying of the programs' memory images. It also allows the operating system to protect its own code from corruption by an erroneous application program and to protect application programs from each other and (to some extent) from themselves. If the combination of virtual memory system and operating system supports swapping, then the computer may be able to run simultaneously programs whose total size exceeds the available physical memory. This is possible because most programs have a small subset (active set) of pages that they reference over significant periods their execution. If too many programs are run at once, then copies to and from disk will become excessively frequent and overall system performance will become unacceptably slow. This is often called thrashing (since the disk is being excessively overworked - thrashed) or paging storm and corresponds to access to the swap medium being three orders of magnitude or more slower than access to main memory.

Note that virtual memory is not a requirement for precompilation of software, even if the software is to be executed on a multiprogramming system. Precompiled software may loaded by the operating system which has the opportunity to carry out address relocation at load time. This suffers by comparison with virtual memory in that a copy of program relocated at load time cannot run at a distinct address once it has started execution.

It is possible to avoid the overhead of address relocation using a process called rebasing, which uses metadata in the executable image header to guarantee to the run-time loader that the image will only run within a certain virtual address space. This technique is used on the system libraries on Win32 platforms, for example.

In embedded systems, swapping is typically not supported—virtual memory is primarily a convenience to cope with software errors.

Windows example

Virtual memory has been a feature of Microsoft Windows since Windows 3.1 in 1992. 386SPART.PAR (or "WIN386.SWP") is a hidden file created by Windows 3.1 for use as a virtual memory swap file. It is generally found in the root directory, however it may appear elsewhere (typically in the WINDOWS directory). Its size depends on how much virtual memory the system has set up under (Control Panel) - Enhanced under "Virtual Memory." If a user moves or deletes this file, Windows will complain the next time it is started with a "Swap File error."

Windows 95 uses a similar file, except it is named WIN386.SWP, and the controls for it are located under Control Panel - System - Performance tab - Virtual Memory.

See also

External links

This article (or an earlier version of it) contains material from FOLDOC, used with permission. Update as needed.