Fedora freezing when running out of memory

I have a laptop with 16 gb of memory. But it has happened quite often that I have so many programs or tabs open that 100% of it is used. Whenever that happens the system completely freezes.
Sometimes after a few minutes it works again with a message saying that an application was killed because it used too much memory. But sometimes it just does not respond until I hard reset it.
I have tried adding a swapfile and disabling zwap. Nothing changes. It is really annoying whenever it happens because I lose my progress and open windows. I don’t mind it killing applications if it runs out of memory but I don’t want my entire computer to freeze.

Are there any tips I could try? thanks

Focus on it workflows if you know you runnout of memory because of tabs reduce those half and do you need all those to be open and eat memory, donyou need all apps to be running all the time if you know you you hitting memory issues.

Check what you need on current task and check what are most memory heavy cases and learn from that.

Second option upgrade your RAM

For browsers install tab suspend plugins (brave has it builtin these days, for firefox / chrome several exist). E.g. New Tab Suspender – Get this Extension for 🦊 Firefox (en-GB)

Next, check what level oom-killer is active, e.g. systemd-oom may be enabled Chris's Wiki :: blog/linux/SystemdOomdNowDisabled
Both can be configured to alter their behavior

System freezing is usually because the oom killer can’t figure out in time what to kill, if you’re into coding you can test this fairly easily by opening a Julia/Python CLI session and allocating memory (and writing to it to prevent COW behavior), then seeing if your ‘fixes’/config changes resolve the issue.

Note that your logs will have the info on why and what was killed.

Those logs will be critical if you have leaking programs.

If you really need all tabs and all programs, and can’t afford more RAM, then consider lower system usage window managers/desktop envs.

There is also more things to consider and start debugging as whatbis the main programs eating the memory, is there memory leaks? Something else using your memory, background processes that you don’t know, unwanted access to system resources the possibilities are so many unless we can start narrow what is the root cause programs or user or the third part aka unknown factor

Sometimes the ‘full’ memory is because an app wants to use swap but the data in swap is larger than the available space – this also can cause lack of memory and freezing or apps being killed.

If this is the situation then one possible fix could be to add a swap partition that would extend the total available space and potentially allow apps to use the swap space portion of the RAM.

With 16G of RAM the default size of ZRAM (8G) can potentially limit the available ram for system use to as little as 8G.

So the current issue is just a bug in the nextcloud sync app. That is not the issue. But I would expect the system to just be able to kill it. But it doesn’t so it completely freezes

Why would it not know what to kill? I already installed early-oom but that really did not change anything.

I have already disabled ZRAM and created a 12 gb swapfile. But it doesn’t change the behaviour once the memory is actually full. The entire system still freezes

There’s a possibility the freezing isn’t necessarily memory related, if it’s a syncing app it could be creating too many pages to be flushed to disk, there used to be a bug/regression in the kernel that triggered 1-2min freezing on large flushing buffers. In any case, if you know which app is causing the leakage, you can restrict its memory usage with cgroups/ulimit.

I know it’s memory related because this is only a recent example of it happening. And often when I for example have a game that is using too much memory it also happens. I also have a extension that shows some system stats
and always when it freezes it shows 99% memory usage :smile:

if you know which app is causing the leakage, you can restrict its memory usage with cgroups/ulimit.

Thanks! I will try that :slight_smile: