0

I work on a computer with 32GB of RAM using Ubuntu 20.04. I often open some VirtualBox machines and keep a lot of stuff open at once. Sometimes I accidentally fill all the RAM memory on the computer and it freezes, so I need to restart it manually. I don't like the solution of using a lot of swap memory because swap memory is also very slow.

I'd like to find a way of killing the process that is using most of the RAM when I accidentally fill it with multiple opened stuff, just so the system will not freeze. Is there any configuration for doing that? Or should I think about a script that will automatically do that when the RAM memory is close to being completely filled?

raylight
  • 461
  • 1
  • 6
  • 15
  • 1
  • reduce swap size 2) make sure the OOM killer is on (should be on by default?) 3) create containers (with cgroups?) for your memory pigs and limit the memory size of the container so other things are not killed first. (I may write up a real answer if someone else doesn't beat me to it, but each of these items needs research for a good answer.)
  • – user10489 Jan 20 '22 at 05:54
  • use zram instead which is much faster than swap: How do I use swap space for emergencies only?. No need to kill any processes – phuclv Jan 20 '22 at 06:49
  • 2
  • Likely zram will be worse than reducing swap. – user10489 Jan 20 '22 at 12:13