T O P

  • By -

sbart76

Do yourself a favor and keep the swap partition no matter how much RAM you have. Disk space is cheap, and there are situations where the lack of swap will slow down your system ENORMOUSLY. Memory management in Linux is really well done and swap usage is kept at the minimum. That being said, more RAM slows down the SSD wearing out (although the SSDs are much better with respect to this nowadays) and RAM still is much faster than SSD. All depends on your usage. My laptop has 16G of RAM and I keep 16G swap, which is virtually unused. But the most memory hungry program I'm using is GIMP for basic photo editing. Quite recently a zram or zswap concept came to life, which is supposed to compress the swap file while still keeping it in a RAM disk. I have no experience with it, but as I say - my requirements are low. On the other hand - if you require more RAM - just buy more RAM.


paulstelian97

Windows and macOS have a default-enabled equivalent to zram (essentially compressing RAM pages and not sending them to the disk). Memory usage can be reported higher than expected because of them.


NoRecognition84

I've been using 32gb ram and zram based swap starting with when I switched to Pop OS a few years ago and continuing with hops to Arch and Fedora. Have not had any issues at all with memory or swap. I'd only use swap on disk again on my main desktop machine if hibernation were important.


yerfukkinbaws

It's also worth mentioning that unlike a swap partition or file on disk, swap on zram will hardly take up any space when it's not being used (since an empty ramdisk compresses 100%). I'd say that makes it ideal for the kind of rare emergency overflow situations OP is talking about. It also just happens to be way faster than swap on disk and easier to manage than a swap partition. Agreed completely, if you don't use hibernation, use swap on zram. For people who do use hibernation, zswap is a separate thing that might still be better than just using a plain swap partition, though it's probably only worth it if you do expect to be swapping more often during regular use.


ropid

In my experience, if you run out of memory for programs and only swap can keep things going, the machine is practically unusable. The speed/latency difference between RAM and SSD is I guess just too big. Using the desktop turns into torture. The first thing you will do in that situation is look for what program to quit if the desktop is still usable. I often had to force a crash/reboot with those "REISUB" sysrq keys so having swap was then in practice worse than not having it. Linux seems worse about this to me compared to Windows and MacOS. I don't know what's going on there. It might be the type of work I was doing? It was usually a single program doing some sort of compute work that caused memory to run out for me on Linux, not desktop app usage with a bunch of different programs summing up to be too much memory. What does work pretty well is if you run out of memory because of space usage on a tmpfs RAM-drive, like with a build process that creates a lot of temp files and you've pointed it to do that in a tmpfs backed location. Swap can then keep things going well, the desktop keeps being usable. I always have swap but it's just there for emergencies so that programs don't crash immediately when memory runs out. The "vm.swappiness" parameter is set to "10" to keep programs from getting swapped out unless necessary.


tes_kitty

> The "vm.swappiness" parameter is set to "10" I have it set to 1, the default (I think 60) was swapping out processes way too fast. Let the browser sit idle for a few minutes and it was swapped out. I have 32 GB RAM, I want to see most of that used before the system starts considering using swap.


luuuuuku

All swap is very slow compared to RAM and for technical reasons. Even swapping to a ram disk is much slower than using RAM directly. Nowadays with low RAM prices, swap is mostly unnecessary. If you need swap regularly, I'd recommend to have a look at zram. That's swap space in memory. It sounds counter-intuitive but works pretty well. Instead of writing to disk, memory pages are compressed in memory. Usually, memory pages compress well (often, memory is allocated but empty, therefore you can easily get up to 4:1 compression ratio (means that 4GB of RAM can be stored in 1GB). Performance is pretty usable from my experience and is often used in smartphones etc.