Hi everyone whats your stance on swap? I currently have on my arch linux install 8 GB of RAM and when I was doing my install I was going to use swap on zram however on all my machines I’ve never noticed any slowdowns or the need for swap. The apps simply just don’t use it I think maybe once or twice it’s used under 500 MB of the swap file
Currently my PC boots in using approx 511 MB I use XFCE as my desktop environment and when I start doing recording or web browsing I tend to use no more than say 2 GB of RAM which doesn’t clear as linux still gives that process space in the RAM unless it is never needed then you can release it.
It seems he makes some good points on why using a swap is beneficial to the well-running of a system regardless the amount of RAM. Perhaps more advanced users can find the time to read the article and comment on it.
Just a thought on how to think of the reasons for swap. If you think of the system as scheduling and controlling its use, then you could picture it knowing that swap exists as a fallback, so it can be more aggressive with memory use - because the consequences are fewer if the results are off. If there is no swap, the system has to make sure that overruns don’t happen, which can be less optimal for performance.
If you want the story in better form - read the links above!
(I am aware that this is not a precise description - but it might do as a shorthand image)
Ive been using swap file and i have no issues. Personally i don’t even think i need swap unless you are going to use suspend and or hibernate.
I’m not big on hibernation and or suspend. On some hardware it works well on others not so much. I don’t particularly want to use it if the graphics won’t come back to life from either. If it works well sure and you have a use. I don’t care about it really.
Never used sleep before Linux, forgot it ever existed, but the speed it goes to sleep and turns back on… uff, can be real nice(more useful on Windows though). I just get 16GB Swap for hibernate(16GB RAM) everytime, though i barely ever used hibernate, sleep i use all the time.
I had an issue with VLC having to be restarted on Pop OS when returning from sleep as it would only play audio, currently that’s not a problem on EoS for me.
The only reason not to have any swap space is to test the system to see if works by removing one of the primary designs features of virtual memory. Why hamper the system by purposefully disabling one of the features of running an operating system designed to use virtual memory? For fun? For sport?
Maybe, if you are installed on a 32Gb (or less) primary storage device, not allocating some swap space gives and extra 1-2Gb of space for file storage. Even in that case, if you are running on a tiny SSD, you probably cannot afford more than 4Gb of ram, so swap space is even more important to have.
Why is this even a concern? Are people here starving for a couple of Gb’s of space? Really?
This is probably an edge case but I have 2 “systems” - Raspberry Pi headless server with 8GB memory and a system on USB flash drive. I use the later on my work computer (16GB memory) when I want a personal computer on a business trip.
The issue in both cases is slow disk I/O and flash memory wear. Both of them run good enough without swap.
no swap over here. no hibernation just suspend and generally i prefer to just fully power off my machines if i’m not using them for long periods anyway. otherwise i have plenty of memory on both my machines so i didnt setup a swap partition on either. i suppose i could setup a swap file but im not really sure that it’s at all necessary for me.
There are two principle reasons that the existence of swap space is desirable.
First, it expands the amount of memory a process may use. Virtual memory and swap space allows a large process to run even if the process is only partially resident. As “old” pages may be swapped out, the amount of memory addressed may easily exceed RAM as demand paging will ensure the pages are reloaded if necessary.
The casual reader1 may think that with a sufficient amount of memory, swap is unnecessary but this brings us to the second reason.
A significant number of the pages referenced by a process early in its life may only be used for initialisation and then never used again. It is better to swap out those pages and create more disk buffers than leave them resident and unused.
I use swap partition. I have never understood that quoted text (part). If I have unused memory and very rarely anything is written to the swap. That’s why I changed the swappiness value to favor more memory. Maybe even the SSD disk will be saved from “unnecessary” writing. Swap is then a fallback.
I never cared to worry about this. Log files get written more often than swap is used. Heck, your browser writes more useless data to its cache folder than swap writes. If you find that swap writing is enough to be valid concern where it might affect the lifetime of an SSD, get more ram. Unless you happen to be writing more than a few hundred GBs to swap regularly, the lifetime of your SSD is not going to notice the difference. And, if you are writing more than a few hundred GBs to swap regularly, you would have been driven mad by the performance drop and bought more ram long ago.
If you dont have Swap and run into a high memory pressure situation your system will plain crash if it has nowhere to put things besides main memory. You should definitely have swap space.
My swap setup is 32GB Ram → 4GB Zram → 8GB Disk Swap
I dont remember what my swapiness is atm but you need it to swap fairly early so that it will swap in time before OOM.
An example. I want to say it was about 6 months ago there was a bug with Inkscape that had caused it to eat all my RAM. I didnt realize it at first and thought it was an unstable system for hardware reasons. The problem was that i only had a couple GB of swap and swapiness set very low so the system wasnt able to swap in time allowing me to stop the situation and recover the system before it crashed.
I use Inkscape from time to time, and for doing very basic things, it would crash quite often. I wonder if this might have anything to do with it on my end, because I love Inkscape, but it is frustrating to use when it crashes before I can even save my work that I have to do it over again.
How exactly do I check my SWAP? And if it’s low, how can I increase it ?
Edit: I have 16GB of Ram, and when I installed EndeavourOS, I installed “Swap to File” as my option I believe.