You can add more RAM or more swap. You can try something like this to add swap, though I didn’t test it:
install -o root -g root -m 0600 /dev/null /swapfile2
fallocate -l 2G /swapfile2
mkswap /swapfile2
swapon /swapfile2
echo "/swapfile2 swap swap auto 0 0" | tee -a /etc/fstab
The other option is to make one bigger swap file.