Page fault
In short: A page fault occurs when a program accesses a memory page that is currently not mapped into RAM. The operating system must then step in.
In more detail: It is not always an error. Usually the access is valid and the page just needs to be loaded (for example from disk). Only if the address is invalid is the program terminated with a segmentation fault.
In Depth
- Minor fault: The page is already in RAM and only needs an entry in the page table. Fast.
- Major fault: The page must be loaded from storage. Millions of times slower.
- Lazy allocation: Memory is often only really provided on first access.
- Segmentation fault: Access to a forbidden address, for example a null pointer.
- Thrashing: Too many major faults because RAM is too small. The system becomes extremely slow.
See also: Virtual memory and paging, Copy-on-write