You can use gparted to resize your partitions and make some space to a new swap partition. Although this works pretty good according to my own experience, before doing it, you should make a backup of all your files just in case.
Ubuntu 20.04 kills a process.
I noticed it myself on a new GCE 20.04 server: I got a notification one of our instances was acting up and before I could log into it Ubuntu had already killed one of 9 MySQL processes. After some investigation it was the one consuming more than 70% of the memory of the server.
This will give you information about "killes processes":
journalctl -a | grep -i "killed process"
dmesg
and syslog
will also show notifications from oom-kill
kernel: [{timestamp}] Out of memory: Killed process {id} ({name}) {process information} oom_score_adj:{number}
I did not see that happen in 18.04 or older versions. The server would just stay slow until I killed a process myself. This works on processes, not when you hibernate/suspend: that will require swap and if there is not hibernate/suspend won't work
Story on out of memory killer:
Whenever your server/process is out of memory, Linux has two ways to handle that, the first one is an OS(Linux) crash and your whole system is down, and the second one is to kill the process (application) making the system run out of memory. The best bet for the second option is to kill the process and save the OS from crashing. In short, the Out-Of-Memory Killer is the process which is responsible for terminating the application to save the kernel from crashing, as it only kills the application and saves the entire OS from crashing. Let’s first discuss how OOM and works and how to control that, and later we will discuss how OOM Killer decides which application to kill.
Personal comment: "as it only kills the application" is probably wrong. I noticed it killed a process and not restart the mysql service.
Best Answer
SWAP can best be described as "virtual memory" I am not an expert on explaining this, but what it does is create a small partition that your system sees as RAM. It then uses this space BEFORE accessing ram when you are running applications, thus allowing your computer to be faster because applications use less actual RAM.
The recommendations I have seen the most (& that I follow) is create a Swap of approximately half your physical ram (if you have 2GB RAM, create 1GB swap) Keep in mind however, if you install Ubuntu 12.10, you don't really have to worry about this since the installer can do it all for you. Unless you want to do it yourself of course!