How to Prevent Linux Memory Thrashing Using zram and systemd-oomd
When a Linux system runs low on RAM, it often enters a thrashing state where disk-based swap causes severe slowdowns before the kernel's OOM killer intervenes. Two tools address this problem: zram creates a compressed in-RAM swap device to keep memory reclaim fast, while systemd-oomd monitors cgroup v2 pressure stall information (PSI) to proactively kill memory-hungry processes before the system locks up. Together, they replace slow disk-backed swap with a more responsive, in-memory alternative supported on modern distros including Debian, Ubuntu, Fedora, and Arch. Setup involves configuring zram-generator with a small config file and enabling systemd-oomd, both of which integrate cleanly with systemd without requiring custom boot scripts. The approach requires kernel PSI support (available since Linux 4.20) and cgroup v2, both of which are defaults on most current Linux distributions.
This is an AI-generated summary. ShortSingh links to the original source for the complete article.
Discussion (0)
Log in to join the discussion and vote.
Log in