22
  • I've just installed Ubuntu 22.04 on my laptop with 8GB ram (no dual boot, ext4 + 20GB linux swap);
  • Installed 2 gnome shell extensions (Dash to panel, Workspace Matrix);
  • My working environment is just vs code, webpack dev server, and chrome;
  • During the active development something dies ~ every 10 minutes. Could not find any error logs, it looks like app is closed (in case of webpack dev server the terminal window is closed). If it's chrome - no chrome processes left.
  • For now, it did not happen with the active app - only background ones die. It's like you save a code, switch to the browser - and there's no browser, or you inspect something in devtools, switch to vs code - and there's no vs code.

What should be the first step investigating this? Where to look for any logs/crash reports?

Kasheftin
  • 333
  • 2
    Have you checked your systemd journals (journalctl) for systemd-oomd closing processes down due to them using excessive memory.. You can disable systemd-oomd. See https://askubuntu.com/questions/1404888/how-do-i-disable-the-systemd-oom-process-killer-in-ubuntu-22-04 if this is the issue – guiverc May 16 '22 at 06:38
  • 1
    Thank you, systemd-oomd closed the apps, I managed to turn off the service with "systemctl disable --now systemd-oomd" – Kasheftin May 16 '22 at 07:19
  • 1
  • Yes. But something else is wrong with ubuntu 22. I see many process clones, it was not that many before. When I turn off systemd-oomd, system sometimes goes to unresponsive state with no other option except hard reset. I had to downgrade to ubuntu 20. – Kasheftin May 17 '22 at 08:04

3 Answers3

24

I had the same problem, and it turned out that systemd-oomd (a userspace out-of-memory (OOM) killer) was killing my applications whenever I was running low on swap space.

As suggested by @guiverc, you can run the following command to see if it is the case for you as well:

journalctl -u systemd-oomd

Example output:

mai 09 07:03:25 caterpillar systemd[1]: Starting Userspace Out-Of-Memory (OOM) Killer...
mai 09 07:03:26 caterpillar systemd[1]: Started Userspace Out-Of-Memory (OOM) Killer.
mai 09 14:05:24 caterpillar systemd-oomd[573]: Killed /user.slice/user-1000.slice/user@1000.service/app.slice/snap.firefox.firefox.d00df170-f05e-4de1-a1c8-4c1d53664dc1.scope due to memory used (7277371392) / to>
mai 10 10:32:34 caterpillar systemd-oomd[573]: Killed /user.slice/user-1000.slice/user@1000.service/app.slice/snap.firefox.firefox.4fad3166-da1d-4084-8a67-8a2ddfe4ab68.scope due to memory used (7352815616) / to>

Two options:

  1. Disable systemd-oomd:

    systemctl disable --now systemd-oomd
    

    For more information: How do I disable the systemd OOM process killer in Ubuntu 22.04?

  2. Increase swap size (recommended).

Pablo Bianchi
  • 15,657
  • 1
    In my case creating/increasing swap is a must. If I recall correctly, previously the default ubuntu setup created ext4 + linux swap partition, but this time ubuntu 22 installation did not created a swap partition. Without swap and systemd-oomd system constantly goes to unresponsive state. – Kasheftin May 23 '22 at 12:11
  • Hey. I'm facing the same issue. I had first allocated 4gb to swap partition but some apps were still crashing. Then I increased it to 16gb, and the OS got a little bit slow, so I decreased it to 8gb and the crash is still happening. Is it something like allocating a high swap partition makes the OS slow? – s.khan Jun 22 '22 at 13:54
  • @s.khan if the system is actually using a lot of swap, that means that it has to transfer data between memory and hard disk all the time, which will make the system slow. The system decides to swap when it doesn't have enough memory, so it shouldn't be using tons of swap space unless it needs more space (or [swappiness(https://askubuntu.com/a/103916/1083397) is set very high). Since apps crash with less swap, it seems that you actually need all that memory/swap space. Your options are to install more RAM or use less memory overall (don't open so many programs/tabs, etc). – Esther Jun 22 '22 at 21:10
  • @Esther I have 8gb ram and allocated more 8gb to swap. System is running (not slow) but when a lot of apps or tabs are open, then one of them crashes randomly. I guess I have to get a new memory stick. Thanks for your explanation mate. – s.khan Jun 23 '22 at 09:54
  • 1
    In my case, I increased swap to 2*RAM (8Gb RAM, swap 165Gb) and everything ok, during thу all day – Lev Kakalashvili Jun 29 '22 at 07:31
  • 1
    Human beings are lazy creatures. If option #2 is the recommended approach as specified, then I recommend it's listed before the other option, so that people who choose the first option they see try it first. – Colm Bhandal Jul 07 '22 at 18:12
  • That was the reason for me also, but disabling systemd-oomd didn't help. Simply, when ram and swap were all full system started to shuts down apps. Only solution was making bigger swap file. – MilanG Jan 24 '23 at 12:17
0

apparently the systemctl disable --now systemd-oomd does not persist on reboot, so we need to do:

sudo systemctl mask systemd-oomd.service

source: https://youtu.be/XotltmuFUyU?t=794

0

For me problem was to small swap file size. Try increasing swap file size first.

Also, some apps (i.e. slack) when installed over snap are very unstable. Try downloading install directly from their website.

MilanG
  • 101