What is the Virtual Memory Paging File?

In computer operating systems, there are many different ways in which an OS can save and retrieve pieces of data from the secondary storage to be used in the main memory. One such scheme of memory management is called paging. In this scheme, the operating system retrieves pieces of data from the secondary storage in the same size blocks otherwise known as pages. The main benefit of a virtual memory paging file is that it permits the physical address space of a certain process to be non-contiguous. Before paging, the systems had to make the whole program fit into storage contiguously and this can cause different fragmentation and storage problems.

Paging is a vital part of the virtual memory implementation in most operating systems, particularly those designed for general purpose. It allows them to utilize the disk storage for the pieces of data that do not fit into the physical Random Access Memory (RAM). It is often implemented as an architecture-specific code exclusively built in the operating system's kernel.

The primary functions of virtual memory paging file are performed when an application attempts to access pages not currently mapped to the physical memory. This occurrence is called page fault. The operating system must take full control and be able to handle the page fault, in such a way that is invisible to the application. Thus, an operating system must:

The necessity to reference the memory at a certain address arises mainly from two sources:

When a certain page has to be launched and all the pages existing in RAM are currently being used, one of the pages existing in RAM must be swapped with the new page requested. The paging system must also determine the page that needs to be swapped by selecting the one that is least needed within a short period of time. There are different page replacement algorithms that attempt to solve such issues.

Most operating systems utilize some estimate of the Least Recently Used or LRU page replacement algorithm or working set primarily based algorithm. If a certain page selected to be swapped has been changed, altered, or modified since the loading, it needs to be written to the auxiliary storage, or else it simply is discarded.

Aside from swapping or trading in pages because they are needed, as a response to the page fault, there are many different strategies and techniques used to guess the pages that might be needed, and hypothetically preload them.

Windows and the Windows logo are trademarks of the Microsoft group of companies.
Microsoft is a registered trademark of Microsoft Corporation in the United States and/or other countries.