When Ubuntu stops responding: Linux Memory Leak

 

After my Linux computer did not respond again and again, I was looking for the cause. The file manager Dolphin, for example, always manages to consume the entire memory, which then brings the computer into an unusable state. Although not a solution, but a way to stabilize the computer, provides the package earlyoom. Earlyoom controls the memory and terminates certain processes if necessary. You can specify which processes earlyoom should preferentially terminate and which should run if possible.

Installation

The installation is easily done via the package manager:

sudo apt install earlyoom

Customization

nano /etc/default/earlyoom

EARLYOOM_ARGS="-r 60 --avoid '(^|/)(deCONZ|dockerd|init|Xorg|ssh|php-fpm|mysqld)$' --prefer '(^|/)(dolphin|bundle)$'"

The --prefer parameter can be used to specify tasks that should be closed preferentially, and "--avoid" to specify tasks that should not be closed if possible.

Status

With the following command the status can be queried: systemctl status earlyoom. The command lists the memory consumption:

systemctl status earlyoom
● earlyoom.service - Early OOM Daemon
     Loaded: loaded (/lib/systemd/system/earlyoom.service; enabled; vendor preset: enabled)
     Active: active (running) since Tue 2021-03-23 18:11:14 CET; 1h 17min ago
       Docs: man:earlyoom(1)
             https://github.com/rfjakob/earlyoom
   Main PID: 277383 (earlyoom)
      Tasks: 1 (limit: 18403)
     Memory: 3.8M
     CGroup: /system.slice/earlyoom.service
             └─277383 /usr/bin/earlyoom -r 60 -m 50 --avoid (^|/)(deCONZ|dockerd|init|Xorg|ssh|php-fpm|mysqld)$ --prefer (^|/)(dolphin|bundle)$

Mär 23 19:19:32 sox earlyoom[277383]: mem avail:  5490 of 15422 MiB (35 %), swap free:  228 of 2047 MiB (11 %)
Mär 23 19:20:32 sox earlyoom[277383]: mem avail:  5411 of 15422 MiB (35 %), swap free:  228 of 2047 MiB (11 %)
Mär 23 19:21:32 sox earlyoom[277383]: mem avail:  5389 of 15422 MiB (34 %), swap free:  228 of 2047 MiB (11 %)
Mär 23 19:22:32 sox earlyoom[277383]: mem avail:  5495 of 15422 MiB (35 %), swap free:  228 of 2047 MiB (11 %)
Mär 23 19:23:32 sox earlyoom[277383]: mem avail:  5472 of 15422 MiB (35 %), swap free:  228 of 2047 MiB (11 %)
Mär 23 19:24:33 sox earlyoom[277383]: mem avail:  5489 of 15422 MiB (35 %), swap free:  228 of 2047 MiB (11 %)
Mär 23 19:25:33 sox earlyoom[277383]: mem avail:  5303 of 15422 MiB (34 %), swap free:  232 of 2047 MiB (11 %)
Mär 23 19:26:33 sox earlyoom[277383]: mem avail:  5329 of 15422 MiB (34 %), swap free:  232 of 2047 MiB (11 %)
Mär 23 19:27:33 sox earlyoom[277383]: mem avail:  5349 of 15422 MiB (34 %), swap free:  233 of 2047 MiB (11 %)
Mär 23 19:28:33 sox earlyoom[277383]: mem avail:  5340 of 15422 MiB (34 %), swap free:  233 of 2047 MiB (11 %)

If the computer reaches the memory limit, specific tasks are killed, in this case dolphin:

$ systemctl status earlyoom
● earlyoom.service - Early OOM Daemon
     Loaded: loaded (/lib/systemd/system/earlyoom.service; enabled; vendor preset: enabled)
     Active: active (running) since Tue 2021-03-23 18:11:14 CET; 49min ago
       Docs: man:earlyoom(1)
             https://github.com/rfjakob/earlyoom
   Main PID: 277383 (earlyoom)
      Tasks: 1 (limit: 18403)
     Memory: 3.5M
     CGroup: /system.slice/earlyoom.service
             └─277383 /usr/bin/earlyoom -r 60 -m 50 --avoid (^|/)(deCONZ|dockerd|init|Xorg|ssh|php-fpm|mysqld)$ --prefer (^|/)(dolphin|bundle)$

Mär 23 18:56:24 sox earlyoom[277383]: sending SIGTERM to process 264065 "dolphin": badness 366, VmRSS 1160 MiB
Mär 23 18:56:24 sox earlyoom[277383]: process exited after 0.0 seconds
Mär 23 18:56:24 sox earlyoom[277383]: mem avail:  2362 of 15422 MiB (15 %), swap free:  220 of 2047 MiB (10 %)
Mär 23 18:56:24 sox earlyoom[277383]: low memory! at or below SIGTERM limits: mem 50 %, swap 10 %
Mär 23 18:56:25 sox earlyoom[277383]: sending SIGTERM to process 16340 "bundle": badness 362, VmRSS 1071 MiB
Mär 23 18:56:27 sox earlyoom[277383]: process exited after 2.8 seconds
Mär 23 18:57:19 sox earlyoom[277383]: mem avail:  4469 of 15422 MiB (28 %), swap free:  264 of 2047 MiB (12 %)
Mär 23 18:58:19 sox earlyoom[277383]: mem avail:  4073 of 15422 MiB (26 %), swap free:  264 of 2047 MiB (12 %)
Mär 23 18:59:19 sox earlyoom[277383]: mem avail:  3737 of 15422 MiB (24 %), swap free:  265 of 2047 MiB (12 %)
Mär 23 19:00:19 sox earlyoom[277383]: mem avail:  3353 of 15422 MiB (21 %), swap free:  266 of 2047 MiB (13 %)


Example 2: here Google Chrome was closed:

systemctl status earlyoom
● earlyoom.service - Early OOM Daemon
     Loaded: loaded (/lib/systemd/system/earlyoom.service; enabled; vendor preset: enabled)
     Active: active (running) since Tue 2021-03-23 18:11:14 CET; 1h 4min ago
       Docs: man:earlyoom(1)
             https://github.com/rfjakob/earlyoom
   Main PID: 277383 (earlyoom)
      Tasks: 1 (limit: 18403)
     Memory: 3.8M
     CGroup: /system.slice/earlyoom.service
             └─277383 /usr/bin/earlyoom -r 60 -m 50 --avoid (^|/)(deCONZ|dockerd|init|Xorg|ssh|php-fpm|mysqld)$ --prefer (^|/)(dolphin|bundle)$

Mär 23 19:15:12 sox earlyoom[277383]: sending SIGTERM to process 266501 "chrome": badness 306, VmRSS 118 MiB
Mär 23 19:15:12 sox earlyoom[277383]: process exited after 0.1 seconds
Mär 23 19:15:12 sox earlyoom[277383]: mem avail:  6155 of 15422 MiB (39 %), swap free:  221 of 2047 MiB (10 %)
Mär 23 19:15:12 sox earlyoom[277383]: low memory! at or below SIGTERM limits: mem 50 %, swap 10 %
Mär 23 19:15:12 sox earlyoom[277383]: sending SIGTERM to process 264964 "chrome": badness 306, VmRSS 114 MiB
Mär 23 19:15:12 sox earlyoom[277383]: process exited after 0.1 seconds
Mär 23 19:15:12 sox earlyoom[277383]: mem avail:  6130 of 15422 MiB (39 %), swap free:  223 of 2047 MiB (10 %)
Mär 23 19:15:12 sox earlyoom[277383]: low memory! at or below SIGTERM limits: mem 50 %, swap 10 %
Mär 23 19:15:12 sox earlyoom[277383]: sending SIGTERM to process 264823 "chrome": badness 306, VmRSS 112 MiB
Mär 23 19:15:12 sox earlyoom[277383]: process exited after 0.1 seconds
positive Bewertung({{pro_count}})
Rate Post:
{{percentage}} % positive
negative Bewertung({{con_count}})

THANK YOU for your review!

Questions / Comments


By continuing to browse the site, you agree to our use of cookies. More Details