Grimoire-
Command
.es

GNU+Linux command memo

No swap but no freeze

If you turn off your swap (to spare save some storage for instance), you might get stranded with an unresponsive computer as soon as Firefox or LibreOffice eats all your RAM. Here is how to avoid this, allowing the Linux kernel to kill your guilty process via its OOM-Killer (Out of Memory Killer) before getting stranded.

Si vous désactivez votre swap (pour économiser du stockage par exemple) vous risquez d’être bloqué avec un ordinateur ne répondant plus dès que Firefox ou LibreOffice aura mangé toute la mémoire RAM. Voici comment éviter ça, en incitant le noyau Linux à tuer le processus le plus gourmand via son OOM-Killer (Out of Memory Killer) avant le blocage.

$ sudo sysctl vm.admin_reserve_kbytes=65536  (1) (2)
1 This raises the admin reserved memory from 8 Mo to 64 Mo, so the OOM-Killer will be invoked while the system still have enough free memory to do it smoothly.
2 65536 = 64 * 1024 ko

To keep this setting at startup :

$ sudo echo "vm.admin_reserve_kbytes=65536" >> /etc/sysctl.conf

As a consequence, you may keep an eye on memory usage and restart Firefox or close unused applications to free some memory and avoid loosing your last LibreOffice work. Although Firefox and LibreOffice don’t suffer too much from an impromptu closing.

I first used a value of 128MO and it worked well. I currently test with 64MO and it seems to be OK. I’ll try with 32MO if the current tests are satisfactory.