Remove sleep image for more space
If you find your mac constantly loses space out of nowhere, check your sleepimage size:
$ls -lh /var/vm
You should see a 'sleepimage' file which in all likelihood is the same size as your machine's total memory. OSX saves what is currently in memory when your machine falls asleep so it can wake up in the same state. Simply removing this file won't cause you any problems as OSX will just create a new one the next time it sleeps:
$sudo rm /var/vm/sleepimage
If you want to turn this feature off completely use:
$sudo pmset -a hibernatemode 0
(the -a flag means under all conditions, otherwise I believe it defaults to -c or while plugged in)
And to restore it use:
$sudo pmset -a hibernatemode 3
This all assumes you're on a laptop, replace the 3 with a 1 if you're on a desktop.
If you're on Mountain Lion and the sleep image still comes back, try this trick:
$sudo touch /var/vm/sleepimage
$sudo chflags uchg /var/vm/sleepimage
(credit to this post for that last hack)
Note that changing to hibernatemode 0
will mean that any unsaved changes while going to hibernation will be lost. Checkout the pmset
section 1 man page for more detail, specifically the SAFE SLEEP ARGUMENTS portion:
$man pmset