swapfile

sudo fallocate -l 4G /swapfile
sudo chmod 600 /swapfile
sudo mkswap /swapfile
sudo swapon /swapfile
sudo swapon -s
free -m
sudo vi /etc/fstab
/swapfile   none    swap    sw    0   0

swappiness

cat /proc/sys/vm/swappiness
sudo sysctl vm.swappiness=10

https://www.digitalocean.com/community/tutorials/how-to-add-swap-on-ubuntu-14-04