Cannot Allocate Memory?

I come across this error every so often, since I run a server with minimal memory, 512MB. Jealous?!?

Most of the time I see this when I'm installing new packages. No need to dole out extra cash for extra memory. You can simply create a swap file on your filesystem to use as swap space.

Step 1: Create a swapfile
$ sudo /bin/dd if=/dev/zero of=/var/swap.1 bs=1M count=1024
$ sudo /sbin/mkswap /var/swap.1
$ sudo /sbin/swapon /var/swap.1
Step 2: ???

Maybe install things, or compile something, or run terrible SQL queries.

Step 3: Profit!

...or turn just swap off. I, myself, have not solved step 2 yet.

$ sudo /sbin/swapoff

Done.