Out Of Memory Freeze Guidance

I seem to always struggle with my system running out of memory and freezing up despite having 32GB of RAM. I know that Fedora comes with Systemd-oomd, but it doesn't seem to be killing processes using too much ram. In testing, it would kill processes, but in the real world, I keep experiencing system freezes with high memory usage. Most recently I've had this happen when the Nextcloud client app was using 24Gb of ram, but I have all sorts of different situations where I am using lots of memory. What should I do to avoid these freezes? Increasing Swap only seems like it will delay the issue, and I'm not sure whether to use something like earlyoom or to modify systemd-oomd especially since I don't fully understand how they work.
28 Replies
Kyle Gospo
Kyle Gospo5mo ago
I would need to understand a lot more about your use case I have never run out of memory on 16GB, let alone 32GB
AntiShulk
AntiShulkOP5mo ago
What are some things I could do to better help myself? I also have freezes on another system with 8GB ram and the freezes happened a lot more often on it. My system would freeze with just a web browser and 1 game open.
Kyle Gospo
Kyle Gospo5mo ago
if all you're doing is playing a game and having a web browser open, I have no idea your machine is made by aliens possibly from mars
AntiShulk
AntiShulkOP5mo ago
basiclsly i tried on my SO’s laptop as well which has an intel cpu (mine are both amd), and the system freezes sometimes with the minecraft mod pack we have. The mod pack performs much better on bazzite than windows, but on bazzite, occasionally it completely freezes the entire system from oom.
Kyle Gospo
Kyle Gospo5mo ago
Typically minecraft uses a set amount of ram, and can't grow past that additionally, I play minecraft w/ a ton of mods on my handhelds, both of which have 16GB of RAM, a portition of which is used as VRAM no OOM
AntiShulk
AntiShulkOP5mo ago
What could be going wrong other than oom?
Kyle Gospo
Kyle Gospo5mo ago
for random crashing? overheating maybe? can grab a ujust logs-last-boot
Kyle Gospo
Kyle Gospo5mo ago
No description
Kyle Gospo
Kyle Gospo5mo ago
No description
Kyle Gospo
Kyle Gospo5mo ago
not even 4GB of ram
AntiShulk
AntiShulkOP5mo ago
I’ve checked lots before and from what i remember i didn’t even see a sign that oom occurred at all, but i’ll check
Kyle Gospo
Kyle Gospo5mo ago
I highly doubt OOM is what you're dealing with not playing minecraft and using a web browser on 32GB
AntiShulk
AntiShulkOP5mo ago
crashes from minecraft and web browser only happened on my partners laptop with 8gb ram I found a github issue about a memory leak in nextcloud desktop client 3.13, but I don't know what to do to make my system kill the process before memory usaage reaches 100% and system freezes. I'll do some testing on my partners 8gb ram laptop to see if I can get minecraft to freeze the system again. The modpack needs around 4gb of ram to run, but when running it, the laptop sometimes locks up and I cant even open tty. This doesn't happen when running the modpack on windows. Maybe it needs some more swap, but I still don't like the system freezes.I'll try to take a picture of system monitor to see if it shows 100% memory usage in minecraft
wolfyreload
wolfyreload5mo ago
A web browser with a couple of extensions and a bunch of tabs open could easily eat 8GB of ram. This is a script I'm running on my work laptop (only 16 GB of ram) that lets me know when I'm running low on RAM, so I can kill stuff before it locks up. Running Kubuntu and not Bazzite but it worked fine last I tested it on Bazzite.
#!/bin/bash

# Minimum available memory (MB) until warning
THRESHOLD=512
# How often to check
INTERVAL=30s

echo "Emitting a warning if less than $THRESHOLD MB of RAM is available..."

while true; do
meminfo=$(cat /proc/meminfo)
available=$(echo "$meminfo" | grep "MemAvailable:" | awk '{ printf "%d", $2/1024}')
swapfree=$(echo "$meminfo" | grep "SwapFree:" | awk '{ printf "%d", $2/1024}')
totalfree=$(($available+$swapfree))
echo "${swapfree}"

message="Available Memory: $available MB
Available Swap: $swapfree MB"

if [ "$totalfree" -lt "$THRESHOLD" ]; then
notify-send -u critical "Low memory warning" "$message"
echo "Low memory warning:"
echo "$message"
fi

echo "DEBUG: $message"
sleep $INTERVAL
done
#!/bin/bash

# Minimum available memory (MB) until warning
THRESHOLD=512
# How often to check
INTERVAL=30s

echo "Emitting a warning if less than $THRESHOLD MB of RAM is available..."

while true; do
meminfo=$(cat /proc/meminfo)
available=$(echo "$meminfo" | grep "MemAvailable:" | awk '{ printf "%d", $2/1024}')
swapfree=$(echo "$meminfo" | grep "SwapFree:" | awk '{ printf "%d", $2/1024}')
totalfree=$(($available+$swapfree))
echo "${swapfree}"

message="Available Memory: $available MB
Available Swap: $swapfree MB"

if [ "$totalfree" -lt "$THRESHOLD" ]; then
notify-send -u critical "Low memory warning" "$message"
echo "Low memory warning:"
echo "$message"
fi

echo "DEBUG: $message"
sleep $INTERVAL
done
I just save the script somewhere on the box, make it executable and add it to autostart. It might work for you too. Change the THRESHOLD variable as needed
AntiShulk
AntiShulkOP5mo ago
that looks smart ill try it out thank you so much
wolfyreload
wolfyreload5mo ago
Won't fix your problem but at least you can close stuff before you run out of memory
AntiShulk
AntiShulkOP5mo ago
No description
AntiShulk
AntiShulkOP5mo ago
heres nextcloud eating all my ram
wolfyreload
wolfyreload5mo ago
That is a memory leak of note. You might be able to restart next cloud when it's ram exceeds a certain amount if you cobble together a script. Hopefully they fix the memory leak, that's a bit of a disaster
AntiShulk
AntiShulkOP5mo ago
The issue is so severe im not sure I can even keep using nextcloud client till it's fixed I wrote a program to just malloc a bunch of memory and nextcloud uses my memory just about as fast as that sometimes
Kyle Gospo
Kyle Gospo5mo ago
well that explains it lol
AntiShulk
AntiShulkOP5mo ago
I still would like for the system would kill the program rather than freeze
wolfyreload
wolfyreload5mo ago
Here is something you might like to play with https://github.com/rfjakob/earlyoom I haven't tried it yet but it should meet your needs... granted it will probably just repeatedly nuke the nextcloud client.
GitHub
GitHub - rfjakob/earlyoom: earlyoom - Early OOM Daemon for Linux
earlyoom - Early OOM Daemon for Linux. Contribute to rfjakob/earlyoom development by creating an account on GitHub.
AntiShulk
AntiShulkOP5mo ago
repeately nuking nextcloud client is better to me than a full system freeze
wolfyreload
wolfyreload5mo ago
Tested earlyoom in Kubuntu, it's working very well so far, will try it in Bazzite a little later but it looks like it's a winner.
AntiShulk
AntiShulkOP5mo ago
Fedora used to have earlyoom but switched to systemd-oomd in fedora 34 https://fedoraproject.org/wiki/Changes/EnableSystemdOomd
AntiShulk
AntiShulkOP5mo ago
earlyoom killed nextcloud-desktop successfully for me on bazzite Earlyoom has been working out well for me. I was working on an app and for some reason launching from integrated vscode terminal causes a pretty bad memory leak, but earlyoom was able to stop it before it caused a system freeze
wolfyreload
wolfyreload5mo ago
My testing of earlyoom has been great too, it's probably going to become one of my default tools that I install on any fresh system.
Want results from more Discord servers?
Add your server