LINUX / A CONCEPT NOTE
Memory & Swap
what 'out of memory' means
Overview · mechanism
pitfall · examples
01 / THE SHORT VERSION
The idea in a few sentences.
RAM holds active process data. When RAM is full, the OS swaps idle pages to a dedicated disk partition (Swap). If both run out, the OOM Killer terminates processes to save the system.
02 / FOLLOW THE MECHANISM
How an oom event occurs
Allocation request
a process requests memory from the kernel.
Swap eviction
kernel moves idle pages to Swap disk to free up RAM.
Exhaustion
RAM and Swap space both reach 100% capacity.
OOM Killer
kernel selects a high-resource consumer process and kills it with SIGKILL.
04 / COMMAND NOTES
Read the command, then the result.
Inspect the flags and arguments before trying an example. Snippets can need local setup, replacement values, or resources in your own environment.
display free and used RAM/Swap in Megabytes
free -mcheck if the kernel killed any process due to OOM
dmesg | grep -i oom05 / CHECK YOURSELF
Could you explain Memory & Swap to a teammate?
Try it out loud in two sentences: what it is, and the one detail that changes the picture. If you stall, the gap is the part to reread.
Up next in Linux & systemsFile Descriptorswhy 'too many open files' happens