I'm running Ubuntu 20.04 on a Lenovo X1C 7th Gen with 16GB RAM. The swap is set to 2GiB.
Just after entering edit mode on a photo in Google Photos (in Firefox), which I'm pretty sure has a serious memory leak (because I've seen it increase memory consumption and slow down the system), the system froze like this:
It stayed like that for a good 3 minutes, with the mouse cursor barely dragging along (good luck taking a screenshot). Eventually it recovered. As you can see, there was plenty of RAM available.
What was going on, and how can I prevent this? /proc/sys/vm/swappiness
is the default, 60.
I've had something similar. Swap is generally expected to be between 1 and 2 times RAM so suggest you increase that. See https://linuxhint.com/change_swap_size_ubuntu/
Since I've set swappiness to 10, I've never had this problem. Also, as Jons suggested, it makes sense to have much more swap, and I don't understand why Linux Mint for example, creates a tiny 1GB swap file on a system with 16GB RAM.