I am a happy ZRAM user for several years now. Basically it makes my 4GB netbook totally usable running Gnome and a Browser with a lot of open tabs.
After reading Debunking zswap and zram myths last week, I thought to give ZSWAP a trial, since the machine had a 3 GB swap partition anyway.
I disabled ZRAM, and enabled ZSWAP and configured it to use the defaults with ZSTD.
I would have expected, that my machine would perform as good as with ZRAM, perhaps a little bit slower because of accessing SWAP instead of just using the RAM.
Surprisingly, my machine froze using ZSWAP after opening at most half the amount of tabs in my browser that I would open when using ZRAM. Was the first freeze on this machine I can remember, after I made the switch to ZRAM.
I increased the zswap.max_pool_percent from its default of 20 percent to 50 percent, which improved the situation a little bit, but still the machine froze again.
I saw the the physical swap was being utilized.
I reverted back to ZRAM, where I configure by default the size to be double the amount of RAM, something like 8 GB (!), again with ZSTD. I could open an insane amount of tabs again, I saw that nothing was swapped to the physical swap, everything was in the RAM disk. No trouble, no freezing.
My question is, why do I observe this? Should not ZSWAP with 50 percent of RAM and a physical SWAP partition outperform ZRAM, at least concerning the number of open tabs in the browser? (I could understand a performance loss because of swapping to the SSD.) Why does the out of memory systemd service not trigger properly with ZSWAP?
Using Debian 13 on an Intel Celeron, in case that should be relevant.
Update:
- I understand, that ZRAM is just a compressed RAM disk and that the 8GB I configure is the size of the compressed data on it, not the actual size it takes in memory
- I understand, that ZSWAP is a caching layer in front of regular swap, integrated into the memory manager subsystem of Linux
According to my understanding, this still does not explain, why ZRAM outperforms ZSWAP. The physical RAM consumption of ZRAM with a lot of open tabs is roughly 2GB. ZSWAP should have had roughly 1.9 GB of RAM for compressed pages ) + 2.9 GB of physical swap. If we assume a compression factor of 3 this sould be roughly 1 GB of additional swap compared to ZRAM, which still performs worse. Again, in both cases ZSTD was used.
Update 2: When I write ‘freeze’, I mean full out of memory crash when using ZSWAP. The machine ‘freezes’ fully, inclusive mouse cursor and nothing happens, even if I leave it alone a few minutes. Sorry, English is my 2nd language.


As I said, ZRAM performs better on low-memory devices. A device with 4 GB of RAM should be considered low by today’s standards.
On devices with 8 GB of memory or more, you won’t see any difference in performance. In certain cases, ZRAM may be exhausted due to low memory.
I ran into this issue with dBeaver [a java applet database manager], it would crash after a while. Also, compiling from the source code may exhaust ZRAM since there’s no physical swap, just like Chris said, you’ll need OOM killer to avoid these situations.
Sorry, I cannot follow you.
There is no reason at all, to not have physical swap when using ZRAM. My physical swap just has a lower priority and is never used, when using ZRAM.
You claim that there is no performance difference, once you have >= 8 GB of RAM. I would assume it is much relevant what kind of usage is thrown at ZSWAP/ZRAM instead of the size. Perhaps you could elaborate, why, in your opinion one will not observe a difference in performance and why this limit would be exactly 8GB? I also use ZRAM on my 8GB machines, with a physical swap partition as backup and physical swap is never touched.
OOM killer is IMHO independent of ZSWAP/ZRAM, because swap space has an upper limit anyway, and a functioning OOM killer is IMHO preferable to a crashed system. I was just surprised, that the OOM killer did not work for me, when using ZSWAP, because IMHO it should have killed the browser in my example.
Finally, why do you claim that ZRAM performs better on low-memory devices, because I do not see a reason that it should, or that such a generic answer makes sense.
Please understand my intention here: I want to understand WHY you make these statements and what is the technical reasoning behind them.