earlyoom is your friend, if you don't care that the process with highest memory usage by default gets killed when shit hits the fan.
You can protect processes of your choice if you configure it beyond a apt install.
http://manpages.ubuntu.com/manpages/bionic/man1/earlyoom.1.h...
You won't need a Swap partition. You might as well create a Swapfile and use it for Swap without the need to repartition the disk.
Being the idiot that I am I thought I wouldn't need a swap file and now everytime my ram is full my system freezes entirely.