I made the switch a few years ago mostly because the only thing I do on computers is write software for the companies I work for; I don’t game, I try but idk just feels like work.
Everything is mostly fine on Linux, minus things like display drivers (pick the wrong nvidia driver and you’ll have crashes), power management (honestly I just use a remote switch to turn off my displays), and random stuff like my gnome classic shell will nearly always crash the moment I try to resume working after a few hours (just kicks me back to the login screen).
But sometimes I go back to windows and I am taken aback as the sheer completeness of the user experience.
Also Linux always hangs hard if I run it out of ram. Windows never does that.
Not going back anytime soon either way.
As usual, prepare for Linux suggestions to the papercuts, but...
I use a program called earlyoom. It will monitor RAM and if you cross a level of utilization (default 95%?) it will kill the worst offenders before the system becomes unresponsive. You can layer on sophistication like protecting certain programs or preferring killing others. I find it invaluable when I am doing data science work and do something stupid which explodes in memory. Annoying that something was killed, but usually better than hosing the entire system -if it crossed 95% it was almost certainly going to hit 100%.
For my purposes it works perfectly - only the Python process will be killed, my IDE or notebook will survive.
Thank you so much for proposing earlyoom, that is exactly what I needed!
Default vfs and vm swap related settings are good for I dunno, 1997.
You have to set swappiness to something like 1 or maybe 10, reduce cache pressure to like 50ish and set dirty ratios/bytes to something reasonable (say around 1GB, half of that for background).
If you keep defaults the system will have too much in caches and they may not be able to flush under memory and swap pressure => hang.
It’s actually amazing you need to tweak any of it to get sane behavior. Other OSes do a much better job at good defaults.
Swap is really interesting. The idea of swap sounds super useful - you get more RAM than you have. The reality is that RAM speeds are so important to fast computing that once you start to need swap, what you really need is more RAM on your machine.
If somebody told me they were running into issues with swap on linux I would ask them why they don't just get more RAM. I'm currently running 32GB and have never used swap on this machine. That includes gaming and local LLM usage (which my GPU does not have enough VRAM for, so normal RAM gets involved).
Swap is not 'super slow extra memory' (well it is, but that's not useful!), it's a place to temporarily store contents of memory for things less important than what wants to be in fast memory right now. Idle apps can (and are) swapped out to have more file cache even on boxes with large RAM. Memory can also be fragmented and you'll have nominally lots of free space, but in reality allocations will fail; in this case, swap can be used to defragment memory instead of OOM killing stuff.
You always want some swap, even if it's 1GB for a 96GB machine.
I think you really are misunderstanding what swap is for.
If your speeds matter, you, and I cannot stress this enough BUY MORE RAM[0]. It's called "swap" not "RAM" so anyone trying to tell you it is "more RAM" is lying to you or woefully naive. It would be as idiotic as having no swap space.
Swap is a cache. Swap will actually help your RAM be even faster! Go look at your RAM usage in a bit more detail. You get a little from using a tool like `htop` but you'll get more from just `cat /proc/meminfo` or `free -wh`. You RAM has tiers of memory inside of it, all RAM is not equal. You should see that some is compressed and a lot is cached. (`/proc/meminfo` will show you there's a whole lot more to this than just "RAM and swap")
I'll put it this way. My machine has 64G of RAM on it and ~9G of swap. Currently the system (rebooted yesterday) is using about 8G of RAM and 200M of swap. Except that's actually a lie, that's what htop tells us. In fact, we need to check from `free`. Of my 62Gi of RAM: 8Gi is used, 7Gi is free, 1Gi is shared, 3Gi is in buffers, 45Gi is cached and 54Gi is available. (Swap is identical: 200M) When my system is running longer, that swap isn't so minimal anymore. Things get paged into it despite having tons of RAM available. This isn't because the OS is dumb, it is because the OS is smart.
The only reason to not have swap is because you really really care about a trivial amount of disk space. But man, disk is cheaper than RAM and these days you're probably using NVMe or at least an SSD.
What you should do:
[0] https://news.ycombinator.com/item?id=45008336[1] https://help.ubuntu.com/community/SwapFaq
[2] https://docs.redhat.com/en/documentation/red_hat_enterprise_...
[3] https://wiki.archlinux.org/title/Swap#Swappiness
I definitely don't misunderstand what swap is for. I've implemented swap for a hobby os.
Swap is absolutely "more RAM" in layman's terms. If you NEED 10GB of memory to have open everything you want on your machine, but you only have 8GB of RAM, swap will make that happen for you. Now ideally the OS is using this for inactive pages (those programs you have open but you aren't actually using), and the nuance to how swap can be used to make the RAM you do have more effective is an interesting attribute of swap (another commenter mentioned swap being used as temporary storage to defrag the physical memory), but every single reference you linked says the same thing - swap is for when you need more memory than you have physical memory for.
You seem to be conflating swaps features with it being anything other than an extension of your physical memory. The primary use of swap is to enable a virtual memory space that is larger than the available physical memory. That can be leveraged for smarter things than "store page with the oldest access time" but fundamentally swap is to enable using more memory than you have more physical memory for. Yes, you can ramp your swappiness and have the OS be more aggressive about paging to disk, this is silly if you have so much unused RAM as the performance implication of a page fault and retrieval from disk is huge.
From your links:
https://help.ubuntu.com/community/SwapFaq: "Swap space is used when your operating system decides that it needs physical memory for active processes and the amount of available (unused) physical memory is insufficient." -> More RAM for your memory heavy usage. In this case if you buy more physical RAM your programs will run faster.
https://docs.redhat.com/en/documentation/red_hat_enterprise_...: "The swap space acts as an extension to the physical memory and allows the system to continue running smoothly even when physical memory is exhausted." and "Swap space in Linux is used when the amount of physical memory (RAM) is full. If the system needs more memory resources and the RAM is full, inactive pages in memory are moved to the swap space." -> More RAM. Slow RAM, but more.
https://wiki.archlinux.org/title/Swap#Swappiness: "Swapping is the process whereby a page of memory is copied to the preconfigured space on the hard disk, called swap space, to free up that page of memory. The combined sizes of the physical memory and the swap space is the amount of virtual memory available." -> Do I need to repeat myself here?
Did you seriously write and link all of that without reading any of it?
>Also Linux always hangs hard if I run it out of ram
disable swap. Programs will crash instead, which may be more useful.
Uhm, no.
Anything what would request memory would just outright die, including even the most basic services.
Source: actually had a system without swap what would just die running `dnf update`. Or quietly die in a week or so if left unattended.
Swap isn’t unlimited, it just delays the inevitable and makes everything slow while doing it. A 4GB swap partition isn’t going to save you if you run your 32GB computer out of memory.
Who the hell would set 4Gb swap for a 32Gb RAM machine in 2025?
A guy with a decade old 64Gb SSD as the only drive in the system?
> and makes everything slow while doing it
It was so when the OS was on a HDD. Nowadays it's a PCIe device with 1 million IOPS.
And five years ago fans of some fruit company run around singing praises on how good their brand new laptops worked with a mere 8Gb of RAM.
It does help. It gives time for the kernel in this situation and also helps in general by allowing to defragment memory. You want to keep a small amount of swap space at all times.
Unless it's some sort of autonomous safety-related process, It's usually better for the process to die so I can just restart it.
Even if it was some sort of safety-related process that had to keep running no matter what, I would probably try to define/control the memory usage better so it wouldn't unexpectedly run orders of magnitude slower.
Programs, including the kernel
I've never had that happen. It usually just kills user-space programs
[0] https://serverfault.com/questions/606185/how-does-vm-overcom...
[1] https://kde.org/plasma-desktop/
[2] https://cutefish-ubuntu.github.io/
> > I don’t game, I try but idk just feels like work. > > I'm surprised by this [...] for the most part, just works
I read that as “playing computer games feels like work” rather than “getting games running feels like work”.
Ah that makes sense. Thanks!
I'm not sure why your quotes got mangled. Maybe it was because when I quote I use two leading spaces? I do that because it makes text verbatim but I think the indentation just helps distinguish the quote better than the > alone. There's also this one that I always forget <https://news.ycombinator.com/formatdoc>
Ubuntu 22.04 user here. Indeed it hangs when out of memory, never had the time to properly address this but i will try to follow the advice provided here in the thread. My servers that run Centos or Debian just do this thing called OOMkill on a ram hungry process, out of the box.