Terme informatique

Linux Swap

A disk space used as an extension of virtual memory.

⌚ About 1 min read
View my favorites

Simple definition

Swap is disk space that Linux can use as an extension of virtual memory when RAM pressure increases.

Technical definition

Swap can be provided by a partition or a file. The kernel can move less-active memory pages to swap to free RAM for processes and cache, but storage access is much slower than physical memory.

How it works / role

Linux balances RAM and swap according to memory pressure and settings such as vm.swappiness. When a swapped page is needed again, it must be read back from storage. Continuous swapping can therefore cause severe performance degradation.

What is it used for?

Temporarily absorb memory spikes, reduce some abrupt out-of-memory situations, and provide space required by specific system scenarios.

Practical example

A server with a swap file can remain available during a short memory spike; the administrator can then review pressure with free -h, swapon --show, or system metrics.

Common issues

  • Swap is disabled or missing although the workload needs it
  • Sustained swapping causes severe slowdown or thrashing
  • The swap file or partition is poorly sized
  • Memory pressure hides a leak or an oversized process

Key takeaway: Swap complements RAM; it is not a substitute for adequate physical memory.

♡ 0