Ubuntu 18.04
I keep having same issue - due to my bad habbits, my Firefox gets to open and hold in memory too many tabs. This causes RAM usage to eventually hit 100%
At which point whole system hardlocks. I can't even move my cursor to press "end process" in system monitor.
Same behavior appears when I run my code and take too much memory - everything stops working, mouse becomes unresponsive.
My guess is obvious - shortage of free memory blocks Gnome or Ubuntu itself.
So my guessed solution would be to make those OS systems reserve memory to always work and respond.
How do I do that?
as requested
$ free -h
total used free shared buff/cache available
Mem: 7,7G 4,3G 281M 1,2G 3,1G 1,9G
Swap: 2,0G 1,5M 2,0G
$ sudo sysctl vm.swappiness
vm.swappiness = 60
swapon
. When swapping, the system will be very slow, but it will still work. When you run out of swap, the system will get no longer work. So you may need more swap space, but the best option is to get into the habit of closing tabs in the browser. If you really need more memory to run your own program, you should get more RAM.top
,htop
, etc. (Note: To go back to your graphical environment use Ctrl+Alt+F2.)