Linux Swap Space Errors — Swap Full, OOM Killer, and Swap Configuration
Errorsystem
Overview
Fix Linux swap space issues including swap full causing system freezes, OOM killer activating, creating swap files, and tuning swappiness for performance.
Key Details
- Swap provides overflow memory when physical RAM is exhausted — prevents OOM kills but is much slower
- Swappiness (0-100) controls how aggressively Linux moves pages from RAM to swap (default: 60)
- OOM Killer activates when both RAM and swap are full, killing the most memory-consuming process
- Swap can be a partition or a file — swap files are easier to resize
- zram provides compressed swap in RAM, faster than disk-based swap (default on some distros)
Common Causes
- Insufficient RAM for the workload causing heavy swap usage and system slowness
- Memory leak in an application gradually filling both RAM and swap
- Swappiness too high causing unnecessary swapping even when RAM is available
- No swap configured, making OOM kills more likely
- Swap file on a slow HDD causing severe performance degradation when swapping
Steps
- 1Check swap usage: free -h or swapon --show
- 2Create a swap file: sudo fallocate -l 4G /swapfile && sudo chmod 600 /swapfile && sudo mkswap /swapfile && sudo swapon /swapfile
- 3Make persistent: add '/swapfile none swap sw 0 0' to /etc/fstab
- 4Tune swappiness: sudo sysctl vm.swappiness=10 (persistent: add to /etc/sysctl.conf)
- 5Identify memory hog: top or htop sorted by memory (press M in top)
- 6Check OOM kills: dmesg | grep -i 'out of memory' or journalctl | grep oom
Tags
swapoom-killermemoryswappinessswapfile
Related Items
More in System
windows-C000021A-status-system-process-terminatedWindows Error 0xC000021A — STATUS SYSTEM PROCESS TERMINATED
Criticalwindows-C0000225-boot-configuration-errorWindows Error 0xC0000225 — Boot Configuration Error
Criticalwindows-C000000F-boot-selection-failedWindows Error 0xC000000F — Boot Selection Failed
Criticalwindows-80004005-unspecified-errorWindows Error 0x80004005 — Unspecified Error
Warningwindows-80070570-file-or-directory-corruptedWindows Error 0x80070570 — File or Directory Corrupted
Errorwindows-system-0xc0000185Windows Error 0xC0000185 — Boot Device Inaccessible
CriticalFrequently Asked Questions
General rule: equal to RAM for systems with 4-8GB, half of RAM for 16GB+. For hibernate support, swap must be at least equal to RAM. Servers with large RAM may need minimal swap (2-4GB).