Sometimes you might need a little bit of help to have more memory, then you can add swap space to your OS.
But this means more writes to I/O which can cause your CPU to spike.
Create the 2GB file:
$ sudo swapon /swapfile
Or if you prefer dd
:
$ sudo dd if=/dev/zero of=/swapfile bs=2048 count=1048576
Set the permissions:
$ sudo chmod 600 /swapfile
Make it a swap file:
$ sudo mkswap /swapfile
Activate the swap:
$ sudo swapon /swapfile
Enable swap to load on boot:
$ cat /etc/fstab
..
/swapfile swap swap defaults 0 0
View swap utilization either with:
$ swapon --show
or:
$ free -m