A page fault is an operation that occurs on a computer with virtual memory, a technique that allows a portion of a hard drive to augment the computer’s physical memory. Most page faults happen when a program attempts to access information that has been placed into the virtual memory file on the hard drive. This is a normal function of virtual memory, and the computer will respond by loading the appropriate information into physical memory. A more serious type of page fault associated with crashes and computer errors can occur when a program looks for information in a memory location that does not exist or is protected. This can by caused by faulty hardware or poorly written software.
Modern computer systems divide memory into smaller chunks known as pages, with each page being accessed by a specific address. Most systems also support a concept known as virtual memory, in which pages can be moved out of the computer’s physical Random Access Memory (RAM) and into a virtual memory file stored on the computer’s hard drive, and back into RAM as needed. The details of this complex memory management scheme are hidden from software; an application has no way of knowing whether or not a page at a given address is loaded in RAM or is in virtual memory. A page fault occurs when a program tries to read or manipulate a portion of memory that is not loaded into RAM or is located at an unexpected address.
Despite the ominous name, a page fault is generally a normal and expected action, and most of the time a user will never notice that the fault has occurred. It is a type of operation known as a “trap,” which means instructions from the program that triggered the fault are temporarily intercepted or trapped while the computer examines the memory address in question. If the address is valid, but not currently loaded in the computer’s RAM, information is transferred from the virtual memory file on the hard drive into physical memory and the program resumes normal operation. This is known as “swapping in” or “paging in,” and is common to nearly every personal computer, regardless of the operating system or amount of RAM installed. Too little RAM, however, causes the computer to constantly shuffle memory pages between the hard disk and physical memory, which will degrade performance.
The second possible outcome of a page fault happens when a requested memory address is found to be invalid or protected. This type of error, also known as a segmentation fault, can be caused by failing memory modules, faulty hard disks, or a misbehaving piece of software. A special signal is sent to the program that triggered the fault, which usually causes the program to abruptly quit. Depending on the operating system, the most serious page faults can cause a computer’s operating system to fail, leaving users with a cryptic Blue Screen of Death (BSoD) or kernel panic message.