Crash because flatpak app Max out RAM (is there a way to prevent this ?)

hey guys, i use fedora silverblue as daily, and is not uncommon this happens, using a flatpak app,usually browser (like brave or firefox) and suddenly it consumes all ram available (16gb) and gnome freezes and then crash. (vitals extension shows 99%)

Idk if is a fedora , linux or flatpak specific problem (because i came from windows and didnt see this behaviour happens).

Is there any way to protect system from this behaviour (let any app to max out ram ) ? Is a flatpak thing ?

You can run an OOM killer such as systemd-oom. This should kill processes when too much memory is being consumed.

That being said, a browser wouldn’t typically consume 100% of RAM like that.

You should also have some amount of swap. Do you have zram enabled?

thanks for your reply.
I think zram is ok as see below

zram status

dev-zram0.device - /dev/zram0
    Follows: unit currently follows state of>
     Loaded: loaded
     Active: active (plugged) since Mon 2024-06-03 10:23:28 -03; 2 weeks 6 days>
     Device: /sys/devices/virtual/block/zram0

swapon --show

/dev/zram0 partition   8G   8G  100

Maybe a better config ?

Do someone could help on this ? Maybe increase Swap iis the way to go ?

Added systemd-oomd and removed gnome, silverblue-team

Added atomic-desktops

No, you need to fight the cause and not reduce the effect.

What exact apps do you use? From what repo?

Try to reproduce with just one app. Add all the other details that may be needed, like other apps running, some specific websites.

Firefox and Chromium have browser “task managers” that can display the used memory of processes.

This “fills up with RAM” may be a memory leak issue but normall with a specific pogram not all of them.

I had an issue with bubblewrap too. Brave Flatpak (and all Chromium Flatpak browsers) uses Zypak, which highly uses bubblewrap/flatpak-spawn, accelerating possible issues.

But Firefox doesnt. So, the exact apps, memory consumption progress please. Use htop for monitoring

thanks for your answer,
basically i always have open brave,thunderbird, obsidian, Anki all of them flatpak (flathub)

I notice that the issue usually happens with brave when the site have some amount of pagination (scrolling)

but i always had 8gb ram with windows and never saw this issue there (crash because max out ram) now with 16gb im seeing quite often on linux

Looks like is a brave flatpak issue (although i used firefox flatpak and it also happens but in another way, with firefox, gnome crashes when was in sleeping state and also make my second monitor stop working, so i would need to reboot every time (i have a topic explaining that issue here in fedora))

What surprises me, is that gnome dont have any safety measure to prevent an app to top ram, it could halt it instead of crash the whole system

I also have memory saver activate on brave to free memory from inactive tabs

If you can reproduce the problem please provide :

journalctl -xe | fpaste --raw-url so we can see the logs.

Also, if you think it’s a flatpak issue you can do some things to debug :

flatpak run --devel name.of-the.App | fpaste --raw-url and paste the link here we can see the log. There are other tools to use in the Flatpak environment like gdb with other commands, but let’s start with that first.

1 Like

thanks, so when the problem happens again i will post here the logs

You can also use flatpak ps :

Instance   PID   Application                   Runtime
3178555051 18914 org.keepassxc.KeePassXC       org.kde.Platform
313888000  20595 org.mozilla.Thunderbird       org.freedesktop.Platform
3309538774 20988 io.gitlab.librewolf-community org.freedesktop.Platform
733043037  21345 org.gnome.Ptyxis.Devel        org.gnome.Platform
1103195624 22052 org.keepassxc.KeePassXC       org.kde.Platform

flatpak enter <instance-id> /bin/sh and navigate to where the Brave Browser debug tools are and run them from within the flatpak environment, or run top for monitoring the running processes.

–devel needs a .Debug runtime and I dont know how to install that, the docs are incomplete I think

While you are in the Flatpak environment you can install the package that’s needed. That is from my faint memory, but do recall being able to do so.

So it would be something like flatpak enter <instance-id> /bin/sh then install what you need from there.

1 Like

That would be handy

You get this cool little new prompt too to let you know you are inside the env :
flatpak run --devel --command=sh org.inkscape.Inkscape

[:package: org.inkscape.Inkscape ~]$

Running top inside the env give you this :

PID USER      PR  NI    VIRT    RES  %CPU  %MEM     TIME+ S COMMAND                                                                                                                                                                      
      1 definit+  20   0    3.6m   1.1m   0.0   0.0   0:00.04 S /usr/bin/bwrap --args 41 -- sh                                                                                                                                               
      2 definit+  20   0    7.9m   4.2m   0.0   0.0   0:00.00 S  `- sh                                                                                                                                                                       
      4 definit+  20   0   11.7m   5.5m   0.0   0.0   0:00.01 R      `- top    

I know :wink:

1 Like