The address space available to a process running in a system with a memory management unit (MMU).
The virtual address space is usually divided into pages, each consisting of 2^N bytes. The bottom N address bits (the offset within a page) is left unchanged and and the upper bits give a (virtual) page number which is mapped by the memory management unit (MMU) to a physical page number. This is recombined with the offset to give a physical address - a location in physical memory (RAM).
Virtual memory is usually much larger than physical memory. Paging allows the excess to be stored on disk and copied to RAM as required. This makes it possible to run programs whose code plus data size is greater than the amount of RAM available. This is known as "demand paged virtual memory". A page is copied from disk to main memory when an attempt is made to access it and it is not already present. This paging is performed automatically by collaboration between the CPU, the MMU and the operating system, and the program is unaware of it.
The performance of a program will depend dramatically on how its memory access pattern interacts with the paging scheme. If accesses exhibit a lot of locality of reference, i.e. each access tends to be close to previous accesses, the performance will be better than if accesses are randomly distributed over the program's address space and thus require more paging.
In a multitasking system, physical memory may contain pages belonging to several programs. Without demand paging, an OS would need to allocate physical memory for the whole of every active program and its data. Such a system might still use an MMU so that each program could be located at the same virtual address and not require run-time relocation. Thus virtual addressing does not necessarily imply the existence of virtual memory. Similarly, a multitasking system might load the whole program and its data into physical memory when it is to be executed and copy it all out to disk when its timeslice expired. Such "swapping" does not imply virtual memory and is less efficient than paging.
Some application programs implement virtual memory wholly in software, by translating every virtual memory access into a file access, but efficient virtual memory requires hardware and operating system support.
(16 Feb 1995)