Virtual memory for sytems with 16GB RAM

In couple occasions when I was capturing Firefox performance traces, Out-of-Memory terminated Firefox.
So, I consulted with Grok and I settled on the following memory configuration

  1. 16 GB RAM
  2. Zram will add a virtual compressed memory of up to additional 16GB
/systemd/zram-generator.conf
[zram0]
zram-size = min(ram * 0.85, 16384)
compression-algorithm = zstd
swap-priority = 100
  1. 64GB Swap file on SSD drive.

What is your memory setup if you have a 16GB RAM

I have 32G memory and I just have setup a 4th of my ram total for zram.

[zram0]
zram-size = ram / 4
compression-algorithm = zstd
fs-type = swap
swap-priority = 100

Why asking Grok? That is stupid. Ask us!

[zram0]
#zram-size = ram / 2
zram-size = 16384
compression-algorithm = zstd
swap-priority = 100
fs-type = swap

I have 64GB of physical Memory.

Since a while back, following one of the “innumerable” discussions on swap, zswap and zram, I decided to switch all my systems from zram to zswap (plus swapfile) mostly because it is already a kernel feature and well integrated into kernel’s own memory management.

On a system with 16G RAM and 16G swapfile (on SSD; I could do with less; this was set up when I still used hibernation and I haven’t bothered to change it), these are my current zswap parameters:


$ grep -r . /sys/module/zswap/parameters/
/sys/module/zswap/parameters/enabled:Y
/sys/module/zswap/parameters/shrinker_enabled:Y
/sys/module/zswap/parameters/max_pool_percent:30
/sys/module/zswap/parameters/compressor:lz4
/sys/module/zswap/parameters/accept_threshold_percent:80

Is this information absolutely necessary? Or rather, what does it improve?

Is it necessary to explicitly define the file system as well?

No.

the device will be formatted as swap, if neither fs-type= nor mount-point= are specified

I should ask you next time. But AI Agents are improving, and I cross-check their “advice” often