Favorite Mac Hacks: Remove huge sleepimage cache file

No replies
Joined: 02/12/2009

When recent Macs sleep, they cache the contents of RAM in a huge file on the boot drive. The file is as big as your RAM plus 750MB. If you're in a situation where you need every ounce of performance/space and don't need to sleep, deleting this file can make a difference. For example, recording studios often set their production Macs to never sleep.

In my test, deleting my file freed up 2GB of space, and the file wasn't recreated by the OS until later. (Although my 2GB of RAM only caused a 2GB cache file, not 2GB+750MB, that's still a lot of drive space.)

To delete it, first check your drive's free space. Then, fire up Terminal (careful if you've never used Terminal, you can easily whack your system) and go to the correct directory with this command:

cd /var/vm

Then, check the contents of the directory:

ls -l

If sleepimage isn't there, nevermind this whole shenanigan, you've got an older Mac (or you hacked the sleep mode, see below). If it is there, delete the sleepimage file:

sudo rm sleepimage

Check your drive free space again to revel in the emptiness.

You can also change the Mac's default behavior so it doesn't ever create the file, getting faster sleep/wake time, but a little more risk of data loss when the power is out. Details on this: