sudo nano /etc/dphys-swapfile
Change (absolute value):
CONF_SWAPSIZE=4096 CONF_MAXSWAP=4096
Update swap file
[ dphys-swapfile setup ] - optional sudo service dphys-swapfile restart
Source: operating systems – How to set up swap space? – Raspberry Pi Stack Exchange