$linuxjunkies
>

swap

also: virtual memory, page file

Swap is disk space used as virtual memory, allowing the system to run more processes than physical RAM can hold by temporarily storing inactive memory pages to disk.

When physical RAM becomes full, the Linux kernel moves less-frequently-used memory pages from RAM to a designated swap partition or file on disk. This frees up physical RAM for active processes, though at a significant performance cost since disk access is much slower than RAM access.

Swap is essential for system stability—without it, out-of-memory conditions can crash applications or the entire system. However, excessive swapping (called "thrashing") degrades performance dramatically. You can view swap usage with free, vmstat, or /proc/swaps.

Example: A system with 4 GB RAM and 4 GB swap can theoretically address 8 GB of memory. If a process uses 6 GB, 2 GB goes to RAM and 4 GB spills into swap, but operations accessing swapped memory run much slower than those in RAM.

Related terms