I've been using Linux as my main OS for 7 years now, but I still can't understand why it freezes when the RAM is overloaded, especially with apps like VSCode and other Electron applications. It begins with the cursor lagging, which only gets worse until the whole system is frozen and I can't do anything. I'm curious if there are ways to prevent this issue, or options other than just rebooting when it happens. I've worked with different window managers on varying RAM sizes over the years (4GB with Cinnamon, 8GB with Qtile, and 16GB with Hyprland), yet the problem persists. Surely there's a solution beyond just adding more memory?
5 Answers
If you're looking for a workaround, have you tried 'EarlyOOM'? It can kill the processes that are hogging memory before you experience the dreaded freeze. Plus, sometimes switching to a console session with Ctrl+Alt+F can help you kill runaway processes without rebooting, but it doesn’t always work. It could be something in your development work that’s leaking memory too!
The freezing happens because the kernel's OOM killer isn't very aggressive; it waits too long to terminate processes that are using too much memory. This behavior might have improved in recent kernels, especially with advances like MGLRU that Ubuntu started using in version 24.04. Check your system’s swap space too – having a proper swap file can help! You might want to consider installing swapspace or even enabling ZRAM for better RAM management.
You should definitely try enabling ZRAM! It compresses data in memory, which can be super helpful, especially if you have limited RAM. I’m using POP OS 22.04, and it comes with ZRAM enabled by default. It really saves a ton of memory!
No doubt about it, you need sufficient swap space set up. The right amount can really make a difference in how your system handles memory overload, so make sure you're not running on low swap.
I totally get what you're saying! It seems like the Linux kernel's swap management isn't always up to scratch. I've been using a dynamic swap space manager called Swapspace, and since I installed it, I haven't had any freezing issues. It's definitely worth a shot!
Related Questions
Can't Load PhpMyadmin On After Server Update
Redirect www to non-www in Apache Conf
How To Check If Your SSL Cert Is SHA 1
Windows TrackPad Gestures