RT Cunningham


zRam, zSwap, Swap or No Swap - Experience Trumps Opinions Every Time

zram - computer memory

I’m using zRam with Linux Mint on my laptop computer these days. For my purposes, it works far better than the other alternatives. Yes, I have experience with most swapping systems, including the Windows paging file.

Published opinions say that when you have enough memory. you don’t need to swap. The only time that’s true is when you never use 100 percent of your memory. One out-of-control process can eat up 100 percent quickly.

Swap - The Default Swapping Mechanism

The default swapping mechanism in Linux is just plain old swap. It’s either set up as a swap partition or a swap file, depending on how it’s installed on the computer. Modern internal storage drives are large enough that worrying about that space is completely unnecessary.

A section on paging at Wikipedia explains it far better than I can.

zSwap - Included with Modern Linux Distributions

I can’t speak for all distributions, of course. The Debian/Ubuntu-based distributions I’ve used in the last few years have it already installed. It just needs to be activated. The documentation page at explains it well enough.

In my experience, zSwap didn’t work much better than plain old swap. When a rogue process caused my computer to use 80-85 percent of its memory, swapping slowed everything down to minutes instead of seconds.

I haven’t used plain old swap in so long, I can’t tell you when swapping started to kick in. With zSwap, and with swappiness set to 10, the system started swapping before it reached 60 percent.

zRam - An Installable Alternative

If you search for and read zRam information and opinions at various sources, it wouldn’t seem to be mature enough to work with. Well, it was included in the mainline Linux kernel at version 3.14 in March 2014. As of the original date of this article (in case I rewrite it later on), it’s been more than five years. I should think it’s pretty mature by now.

When I installed Linux Mint as a Windows and Linux dual-booting system, I immediately enabled zSwap. zSwap works in conjunction with a swap file or partition. Based on how I used Linux, I would have to eventually log out and log back in just to free up the main memory (without even looking at how much swap was being used).

When I removed every swapping mechanism and installed zRam, things changed for the better. Ever since I’ve had zRam installed, I’ve yet to see any swap being used at all under normal circumstances. Yesterday, I opened enough web browser tabs to force it to start swapping. That didn’t happen until memory usage exceeded 80 percent.

I once wrote, along with other Linux tips, that zRam shouldn’t be used on systems with less than eight gigabytes of memory. It seems I’m wrong more often than right. I think I had it in reverse, that it shouldn’t be used on systems with eight gigabytes or more, and even that’s probably wrong. There’s no reason it can’t be used instead of any other swapping mechanism regardless of how much memory is available.

You can read more about zRam at the documentation page.

Controlling zRam on Ubuntu, Linux Mint and Other Derivatives

Installing zRam (sudo apt install zram-config) also installs the zramctl program. I don’t know how zRam is controlled on other distributions and I haven’t explored the options yet. I’m still using zRam with its default options and I’ll probably leave it that way.

I have two laptop computers and I don’t know how long they’ll last, since I only use one at a time. If memory serves me, they should last for at last another eight years combined. By the time I need to buy a new one, I’ll probably get one with so much memory that swapping will be an afterthought.

Unless, of course, laptop computers no longer exist when both of mine no longer work. With the pace of technology, you never know.

Share: Facebook | Twitter

By RT Cunningham
August 30, 2019