Assigning more RAM, as suggested in the accepted answer by @sogu, will probably cost you money.
You can alternatively solve this problem free-of-charge by assigning swap space instead. This blog post provides a simple few commands to allocate 1G of swap space, which was enough for conda to install most packages in my case:
sudo fallocate -l 1G /swapfile
sudo chmod 600 /swapfile
sudo mkswap /swapfile
sudo swapon /swapfile
sudo cp /etc/fstab /etc/fstab.bak
echo '/swapfile none swap sw 0 0' | sudo tee -a /etc/fstab
Comments