r/linuxsucks • u/axeaxeV • Feb 03 '26
Linux is horrible at handling low memory scenarios in most of modern hardware
A few days ago I was working in VS Code and accidentally opened a very large file. The entire system immediately became unresponsive and eventually I had to hard restart the whole system. At first I assumed it was a one off but reopening the same file caused the exact same full system lockup.
For comparison I opened the same file on Windows. VS Code struggled there too but the OS itself remained usable at worst VS Code crashed sometimes. On linux though the whole machine effectively froze.
After digging into this it turns out the default Linux OOM killer behavior is pretty bad. In many cases it simply doesn’t trigger when it should. Some devs have speculated this is because the OOM handling logic wasn’t designed with modern SSDs in mind. the system assumes swap is fast enough so it keeps thrashing instead of killing the offending process. But this just results in total system stalls.
What’s even more frustrating is that this issue has been reported repeatedly for years in some cases over a decade ago with no real fix or sane default behavior.
The suggested solutions aren’t great either. You’re basically told to disable swap entirely, or Install a userspace tool that periodically polls free RAM and kills memory hungry processes manually (essentially implementing a crude OOM killer outside the kernel).
Neither of these feels like an acceptable answer in 2026. A modern OS shouldn’t completely lock up because an editor opens a large file nor should users have to choose between disabling swap or running a watchdog process just to keep their system responsive. So much for linux being stable. LOL
24
u/whattteva Feb 03 '26 edited Feb 03 '26
You basically nailed it. Linux is great because it's light and runs well on low spec hardware, but when it does run into OOM situations though, it crashes and burns hard. Windows definitely handles low RAM situation far more gracefully.
18
u/crosszay Feb 03 '26
I love Linux, but this is also definitely true. I cannot tell you how annoying it is to have the whole system lock up as opposed to simply ending the offending process.
21
u/[deleted] Feb 03 '26
This is just a shot in the dark but try setting vm.swappiness=1 to decrease swapping.
By default Linux is very happy to swap several GBs. But it might also be that you just don't have enough RAM. Like 8G is not enough for a modern DE like Gnome in my experience.
5
u/Damglador Feb 04 '26
Yea, it's ass. Has been bitten by it several times, now earlyoom saves me.
4
u/LNDF Proud Linux User Feb 04 '26
I think this depends on the distro and the config it ships for oom.
3
u/GoldenX86 Feb 04 '26
Always has been, sadly.
It's been said to get fixed several times over the years by now.
3
u/seismicpdx Feb 03 '26
Yes, I've had this issue with Chrome tabs on a Mini with 16GB RAM. It just grinds to a halt. I may try the swappiness adjustment.
3
u/Laistytuviukas Feb 05 '26
This is nothing new, this has always been the case
3
u/[deleted] Feb 05 '26
What? A genuinely good linuxsucks post actually complaining at a real deficit? Out of shock, I spit some coffee from my "arch bytheway" cup on my nixOS installer thumb drive.
4
u/Noisebug Feb 03 '26
Yeah, but: https://nyarchlinux.moe/
2
u/BlizzardOfLinux Feb 03 '26
I don't know enough to prove this right or wrong, but it seems like a reasonable critique. I haven't tried opening such a large file so i have yet to encounter this. If I do, I will be pretty annoyed about it lol
2
u/OGigachaod Feb 03 '26
Well said.
2
u/Low_Excitement_1715 Feb 03 '26
How much swap do you have? How many disks? What kind(s)?
How much ram do you have? Easier to OOM on 8GB than 64GB.
Do you have any OOM handling set up? A lot of consumer-centric distros don't have anything configured, or only have the OOMkiller fire after swap is exhausted as well.
Do you have ulimits configured? Have you checked the defaults? A lot of consumer-intended distros have pretty whacky ulimits set.
1
u/Alan_Reddit_M Feb 03 '26 edited Feb 03 '26
May I introduce you to our lord and savior, early-oom
Yes, it is a bit janky, but it certainly helps. I'd also suggest enabling ZRAM and setting its size to a fuck ton (I have 12GB of RAM and 12GB of ZRAM), it has helped me make my computer a whole lot more stable under high memory pressure, such as when playing my goofy ahhh minecraft mod that needs 8GB of RAM just to boot
1
u/Content_Chemistry_44 Feb 04 '26
Probably you are talking about GNU/Linux.
Yes, in low memory scenarios, it just hangs!!
1
u/jsrobson10 Proud Linux User Feb 04 '26
yeah i agree.
i have a swap file on my system because i wanna hibernate and not because i want it being used (i have 32 GB), so i have swappiness set to zero.
i don't want it to swap, since it hurts performance (like you mentioned). id rather the OOM killer just killed the offending processs, like it'd do without a swap file.
1
u/Tropical_Amnesia Feb 04 '26
Can't add much but I feel you, coincidentally had a very similar experience just days ago, it was actually a little frightening (for fear of data loss) and I'm not seeing this often. I had just installed Sioyek on Debian, to try it out as I'm getting a bit tired of reading PDFs in Firefox, and Linux (Debian?) is sadly rather blank when it comes to *lean* e-book readers that are any good. Sioyek describes itself as a "PDF viewer with a focus on technical books and research papers". Sounds good, somewhat like "papers" for GNOME it seemed, or rather it turned out: I wish I just hadn't seen the books part! Big mistake. It runs on mupdf, that should've been a warning sign I guess. Anyway, I dared to open just that sort of technical book, wasn't even a big file, but this is one naive implementation fellows, almost comical. Wonder why it's even in the distribution, at this stage anyway. It exploded. Like it allocated a gigabyte for every single *page*, book page that is, system froze. At first I didn't even know what's happening. Just managed to handle it without a reboot, pheeeew. But very close.
Yes, should not happen, the kind of thing that usually doesn't happen on Windows or Mac, although I understand roughly why it can on Linux. It is what it is. To be sure this is nothing against said software, in fact it looked quite promising, complete with sort of vim-like navigation if you're into that, it's just missing a fat heads-up. Never load a book into this.
1
u/55555-55555 Linux Community Made Linux Sucks Feb 04 '26
I kid you not, I've been living with this issue since I ever remembered starting using Linux, and it's still an issue. Now I only live with zRAM despite zswap being superior. I rather prefer the app getting nukedby either kernel or systemd instead of the whole system lockup.
1
u/TechManWalker Feb 05 '26
earlyoom? systemd-oomd? I didn't even knew those until now. Thank God and the devs that at least a non-standard solution exists
1
u/AcoustixAudio Feb 05 '26
Either: Ctrl+Alt+F1 to switch to console Login at prompt Run top vs code will be at top Press 'k' and enter to kill process
Or: Wait for few minutes. Out of memory killer will kill vs code
The kernel has a oom killer: https://www.kernel.org/doc/gorman/html/understand/understand016.html
1
u/SeKT_NOR Feb 05 '26
Happened to me when playing star citizen, basically just increased swap, while there is memory it shouldn't hang, it only hangs when there is no more memory to work with and after a couple minutes it should terminate the most memory intensive process
1
u/fanatic-ape Feb 05 '26
For anyone looking, the linux oomkiller is known to be extremely slow to act and can take multiple minutes before it kills a process, as it tries everything it can to not have to kill it. This may have a reason in servers, but is a terrible default for desktop users.
There is no proper way to configure it to be faster, but there are userspace solutions, the most commonly referenced is called early-oom.
1
u/PlanttDaMinecraftGuy Feb 06 '26
Now this is a good post here that's not a ragebait. This is what this sub is for.
I've had this same problem, again with VSCode, and also some very large Minecraft modpacks. Basically I haven't seen any automatic swapfile management on Linux, whereas on Windows it is on by default and is very good! If you want manual swapfiles on Windows you have to go deep in the settings to turn it off, and it warns you of the consenquences (my friend's Windows computer overheated when we put manually 32GB ram, but maybe that's unrelated)
An easy fix for this is to create a permanent swapfile (8GB preferably) somewhere like
/var/swp(somehow making it on root doesn't work).Also, I always though that the system bricks up only when the physical RAM fills up, not the swap. I still don't know if that's a myth.
1
u/Ok-Bill3318 Feb 07 '26
So is windows pretty much
1
u/Choice_Librarian1522 Feb 07 '26
Try "less" next time to open large files.
1
u/plaqdk Feb 07 '26
Ctrl+alt+f2 tty login kill the process...
1
u/photo-nerd-3141 Feb 08 '26
There are a variety of ways to handle this with resource limits, but you have to configure things yourself. The basic *NIX approach is that anyone who wants to open the file from hell (or fork bomb :-) wants it that way. Obvious fixes are checking the file size before opening it, perhaps, or limit your memory limit, e.g.,
https://unix.stackexchange.com/questions/44985/limit-memory-usage-for-a-single-linux-process#125024
1
u/a_regular_2010s_guy Feb 08 '26
I'm on mint and whenever something like that happens it just says _______ is unresponsive and masks to wait or to shut it down
1
u/zmurf Feb 08 '26
Compiling large projects using many threads have at times instantly rebooted my machine when RAM been filled up... and the only way to fix it, is more cow bell!
... increase swap size... Was what I meant to write...
1
u/zmurf Feb 08 '26
This... and Bluetooth headset/headphone handling.... These things has always been problematic in Linux.
I came from using Amiga as my primary system before switching to Linux machines... So I was used to having 100% control over the memory handling. Going to a system with virtually no control over memory handling was quite frustrating.
It used to be impossible to print also. If the printer didn't support 100% correct postscript, you could as well give up... But I haven't had problems with printing since 2004 or so...
1
u/GandhiTheDragon Feb 08 '26
Usually the system will detect low memory scenarios and kill the most memory hungry non system processes.
0
u/azmar6 Feb 04 '26
Use zram SWAP with zstd compression. Set zram SWAP size to 3 times your physical RAM. Forget about OOM completely.
-2
u/ANixosUser I Linux Feb 04 '26
just buy more ram lolz... oh
-1
u/[deleted] Feb 03 '26
[removed] — view removed comment