How can I prevent oom-kill without increasing RAM

1.9k views Asked by At

I have 256MB Orange Pi Zero that I want to run OctoPrint on. It starts and run for some time, then it gets killed because of out of memory. I can't add more RAM so I tried to increase swap size. I added 1GB but it doesn't help. Also I don't understand why but I have "htop" running at the same time, and from what it shows the swap ("Swp") isn't used, and there is still free 1/3 of physical memory ("Mem") all the time. What is going on. I don't care about the performance at this point. Is there any way I can force it to run on swap?

1

There are 1 answers

1
Tony Stark On

You could tell OOM Killer to ignore the OctoPrint process.

echo -17 > /proc/$OCTO_PRINT_PID/oom_adj

See https://backdrift.org/oom-killer-how-to-create-oom-exclusions-in-linux.

Or you could adjust swappiness so that Linux swaps earlier. See https://www.howtoforge.com/tutorial/linux-swappiness/.

sudo sysctl vm.swappiness=100