Do not buy RAM, compress!

Open original

The author ran out of memory on a 32GB workstation and turned to zram, a Linux feature that compresses RAM to fit more data in the same space. A later update says zswap is the better choice for most setups, and the author plans to switch.

  • Compression ratios of around 1:3 to 1:4 are common, so a test with 5.7GB of data fit in 1.7GB of RAM.
  • The cost is a small amount of extra CPU use and some latency, which the author describes as barely noticeable.
  • Not every Linux distro enables RAM compression by default; Fedora and Pop!_OS do, Ubuntu does not.
  • After community feedback, the author concluded zswap beats zram for most situations and is switching to it.

The core argument is simple: instead of buying more RAM, compress what's already in memory. The author ran out of memory on a 32GB workstation while opening a long list of websites in Firefox, and turned to zram, a Linux feature that compresses memory pages in RAM. In their test, 5.7GB of data fit into 1.7GB of physical RAM, a compression ratio of about 1:3.35. They note that compression ratios up to 1:4 are common, and that the cost is a bit more CPU work and some added latency, which they consider hard to notice in practice. They also point out that Windows, macOS and many Android phones already do this, while distributions differ: Fedora and Pop!_OS enable it by default, Ubuntu does not, and Amazon Linux only turns it on for smaller VMs. The author ties this to cloud spending too, recalling SaaS machines that were upgraded to double size while the CPUs sat idle, and suggesting compression could have roughly halved that bill. The article is also a post-publication update. After it reached Hacker News, the author read two pieces, one by Hayden James and one by Chris Down, and concluded that zswap is the better choice for most people. zswap works differently: it acts as a compressed cache in front of a swap device rather than creating a compressed swap device in RAM itself. The author says they will switch their own configuration from zram to zswap. The update is dated 20 November 2026 in the text, which is worth double-checking against the publication date. Beyond the Linux specifics, the piece is a pitch for the author's freelance services, with a "get in touch" section for hiring a software engineer or technical leader. The technical claims are concrete enough to verify: the test figures, the distribution defaults, and the zswap correction are all things a reader can check against the Arch Linux wiki the author links to, or the two follow-up articles they cite.

Ask about this article