First, see if there is set swap on Ubuntu:
sudo swapon --show
If nothing in the display, indicating that there is no set swap.
Create a swap file, and activate:
sudo fallocate -l 1G /swapfile
sudo chmod 600 /swapfile
sudo swapon /swapfile
View, swapon there content.
See more swap settings here https://linuxize.com/post/how-to-add-swap-space-on-ubuntu-18-04/