Suppose I turn off swap, and all RAM gets used up. What will happen?
Will the machine freeze? Will Ubuntu (or the Linux kernel) intelligently close the programs consuming too much memory?
Background: I have an old desktop with 3 GB RAM, which works smoothly with Xubuntu 20.04. When I open many tabs in Firefox and some large PDF files simultaneously, about 2.4-2.5 GB RAM is utilized, and about 700-800 MB of swap space is used. However the desktop interface becomes somewhat slow to respond, and sometimes becomes unresponsive while loading RAM -> swap.
It again becomes responsive when I close some of these softwares and run the command sudo swapoff -a && sudo swapon -a
, so that the content of swap is loaded back into RAM.
I found that the system does not become slow to respond when swap is turned off before opening such programs (I was careful so not to consume all the RAM).
I want to know whether there can be any severe issue if I turn off the swap permanently and all RAM is used up. Of course, I would try to ensure that it does not happen. However, I would prefer to use a faster system (while being careful not to open too many programs simultaneosly), rather than using a slower system with a larger effective memory (physical RAM + swap).