Virtual Memory


Virtual memory simulates more random access memory (RAM) than actually exists, allowing the computer to run larger programs and multiple programs concurrently. It is defined as follows:

Virtual memory gives an application program the impression that it has contiguous working memory, while in fact it may be physically fragmented and may even overflow on to disk storage.
The figure shows virtual memory allows more programs to be opened simultaneously by using the hard disk as temporary storage of memory pages.

The computer’s real memory is broken up into smaller segments, called “pages,” typically 4 KB in size.

When real memory fills up, pages not currently in use by open applications are written to a virtual memory “swap file” on the disk for temporary storage. When any swapped out page is required again, once again a page in real memory is written to the disk to make room, and the disk page is retrieved. However, when a user has too many open programs, there can be excessive amounts of page swapping, causing applications to slow down. The figure shows program A needs a page from the disk, and a page from program C is swapped out to make room.