Creating a swap file
Swap files are used to increase a machine's total memory without actually increasing the physical memory that they have. Swap files are disk-based memory, which makes them significantly slower, somewhere between 5-15% of what real memory can handle in terms of speed. This is fine if the swappiness and swap priorities are set correctly, the system allocates swap memory for applications that are not fetched frequently and keeps the fast memory for applications that actually need it.
How to make a swapfile
cd /
sudo fallocate -l 16G /swapfile
sudo chmod 600 /swapfile
sudo mkswap /swapfile
sudo swapon /swapfile