Our default install of FreeBSD does not include swap space configured. If you are attempting to compile, or do more memory intensive tasks, you will need to have swap created and enabled.
First, confirm swap status with swapinfo - which should return a blank response for data.
About Swap
The convention in the past was to create a swap file double the system RAM, but with modern SSD backed storage, there is no need to waste extra space just on swap- you probably can get away with an amount much less than your total amount of RAM. If you find your process gets killed, run dmesg and see why- if the swap file is too small, you can double it and create it again in a jiffy.
Creating and enabling a swap file
As an example we'll create a 512 M swap file in /usr/swap0 - you may change the size, location, or file name as you wish.
- Create the file:
dd if=/dev/zero of=/usr/swap0 bs=1m count=512
- Set permissions
chmod 0600 /usr/swap0
- Add an entry to /etc/fstab so that the swap file is persistent across reboots
md99 none swap sw,file=/usr/swap0,late 0 0
- Enable Swap
swapon -aL
- Check swap is now enabled using swapinfo