[HowTo] deal with low memory before it becomes a problem

Difficulty: ★☆☆☆☆


You have a PC. It often hangs or slows down terrifically, you cannot even move the cursor on the screen, you wait 5 minutes for the system to defrost from its cryogenic state. You tell yourself “maybe 200 tabs was too much…” But in life, there’s hope. Hope for a magical solution to appear right in front of you, as if the sky gifted you magnificence. Here is that solution. It is called Earlyoom. Yes, my friends, easiness never has been so easy!

“Okay, but what does that random piece of software does?”, you might ask.
It checks your memory about once every 10 seconds, or more if needed, and it will send the SIGTERM signal to the process that uses the most memory in the opinion of the kernel if you are running low in memory, say about 10% of total swap and available memory!


Step 1: Install earlyoom

You may open a terminal and enter:

sudo pacman -S earlyoom

Easy peasy!


Step 2: Enable the service

In the terminal, execute:

sudo systemctl enable earlyoom
sudo systemctl start earlyoom

to start the service.
Voilà! Finished!

Where is the configuration file located?

  • The configuration file is indeed located in /etc/default/earlyoom

  • To edit, simply execute:

    sudo nano /etc/default/earlyoom
    
  • Press Ctrl+S to save,
  • Press Ctrl+X to exit.

How to know if the daemon is running?

  • Simply execute sudo systemctl status earlyoom

What are the available commands/configurations?

  • You may execute earlyoom -h to list all available commands!

  • The manual page is accessible by invoking man earlyoom.


That concludes this memory tip, shall your nugget not run like a potato any more!
Feel free to critique and/or leave suggestions below!

5 Likes

So deep! :relieved:

:face_with_hand_over_mouth::rofl:

2 Likes

Right! So if you’re working on a large project and then open a browser tab you’re in risk of the project being killed. Not my piece of pie, thanks.

1 Like

Indeed, you don’t want to be writing a novel about trees, and loose all your cheerful work.

This is why you may whitelist certain apps in the config!

Plus, i tested it, and wĥile it sends the sigterm signal–say you’re on Libre Office, it will ask you if you are certain to quit so you may just hit cancel!
As a scientist myself, I use earlyoom on almost all my systems, and never had such issue!

Have a wonderful day!

3 Likes