Computer Memory, Physical and Virtual Memory
Computer Memory, Physical and Virtual Memory
Physical and virtual memory are related forms of digital memory, that is, the storage of information within computers and other digital devices. Physical memory exists on chips (random-access memory or RAM) and on bulk storage devices such as tapes, optical disks, and hard disks. Before a program can be executed, it must first load into RAM memory (also termed main memory). Since RAM is expensive and volatile (or if not volatile, slow)—that is, loses its data when the power is off—programs and data are stored on hard drives or other bulk devices until needed for execution.
Virtual memory is a management process whereby data (e.g., programming code) can be rapidly exchanged between physical memory storage locations and RAM memory during execution. The rapid interchanges of data are (hopefully) seamless and transparent to the user, who perceives the machine as having more RAM than it actually does. The use of virtual memory allows the use of larger programs and enables those programs to run faster.
In modern operating systems, data can be constantly exchanged between the hard disk and RAM memory via virtual memory. A process termed swapping is used to exchange data via virtual memory. The use of virtual memory makes it appear that a computer has a greater RAM capacity because virtual memory allows the emulation of the transfer of whole blocks of data, enabling programs to run smoothly and efficiently. Instead of trying to put data into often-limited volatile RAM memory, data is actually written onto the hard disk. Accordingly, the size of virtual memory is limited only by the size of the hard disk, or the space allocated to virtual memory on the hard disk. When information is needed in RAM, the exchanges system rapidly swaps blocks of memory (also often termed pages of memory) between RAM and the hard disk.
Modern virtual-memory systems replace earlier forms of physical file swapping and fragmentation of programs.
In a sense, virtual memory is a specialized secondary type of data storage, and a portion of the hard drive is dedicated to the storage of specialized virtual-memory files (also termed pages). The area of the hard drive dedicated to storing blocks of data to be swapped via virtual memory interface is termed the page file. In most operating systems, there is a preset size for the page file area of the hard disk, and page files can exist on multiple disk drives. Users of most modern operating systems can, however, vary the size of the page file to meet specific performance requirements. As with the page file size, although the actual size of the pages is preset, modern operating systems usually allow the user to vary the size of the page. Virtual memory pages range in size from a thousand bites to many megabytes.
The use of virtual memory allows an entire block of data or programming (e.g., an application process) to reside in virtual memory, while only the part of the code being executed is in physical memory. Accordingly, the use of virtual memory allows operating systems to run many programs and thus, increase the degree of multiprogramming within an operating system.
Virtual memory integration is accomplished through either a process termed demand-segmentation or through another process termed demand-paging. Demand-paging is more common because it is simpler in design. Demand-paging virtual-memory processes do not transfer data from disk to RAM until the program calls for the page. There are also anticipatory paging processes utilized by operating systems that attempt to read ahead and execute the transfer of data before the data is actually required to be in RAM. After data is paged, paging processes track memory usage and constantly call data back and forth between RAM and the hard disk. Page states (valid or invalid, available or unavailable to the CPU) are registered in the virtual page table. When applications attempt to access invalid pages, a virtual-memory manager that initiates memory swapping intercepts the page fault message. Rapid translation of virtual addresses into a real physical address is via a process termed mapping. Mapping is a critical concept to the virtual-memory process. Virtual-memory mapping works by linking real hardware addresses (a physical storage address) for a block or page of stored data to a virtual address maintained by the virtual-memory process. The registry of virtual address allows for the selective and randomized translation of data from otherwise serial reading drives. In essence, virtual-memory processes supply alternate memory addresses for data, and programs can rapidly utilize data by using these virtual addresses instead of the physical address of the data page.
Virtual memory is a part of many operating systems, including Windows, but is not a feature of DOS. In addition to increasing the speed of execution and operational size of programs (lines of code), the use of virtual memory systems provide a valuable economic benefit. Hard-disk memory is currently far less expensive than RAM memory. Accordingly, the use of virtual memory allows the design of high-capacity computing systems at a relatively low cost.
Although swaps of pages of data (specific lengths of data or clocks of data) via virtual-memory swaps between the hard drive and RAM memory are very fast, an over-reliance upon virtual-memory swaps can slow overall system performance. If the amount of the hard drive dedicated to storing page files is insufficient to meet the demands of a system that relies heavily on the exchange of data via virtual memory, it is possible for users to receive “OUT OF MEMORY” messages and faults, even though they have large amounts of unused hard disk space.
By 2006, personal computers with RAM capacities of in the several-gigabyte (1 gigabyte equals 1 billion bytes) range were widely available in the United States and many personal computers boasted hard disk capacities of hundreds of GB, with one-terabye (one thousand gigabyte, one trillion byte) drives due on the market within the next year or two. The relative limits of both hard disk capacity and RAM memory capacity improve steadily with advances in microchip and magnetic storage technology.
See also Computer languages; Computer memory, physical and virtual memory; Computer software; Computer, analog; Computer, digital.