MacOS – get back more disk space when I restart the Macbook on Mountain Lion 10.8.3

hard drivemacosssd

I frequently run low on disk space on my laptop. When I'm down to my last gig or so on my 256MB SSD (as reported by iStat Menu), I'll get various warnings from the OS and apps saying that I'm running out of space.

I can empty my trash, which buys me a little more time, but eventually I will run out of space and won't have any more to empty in my trash.

The weird thing I have discovered is that if I reboot my mac, I get another 8-10 gigs of storage back for free. After a reboot just now, iStat is now reporting 10.83GB free, and the Finder confirms it (reporting 10.96).

What I don't understand is where this storage is coming from.

At first I thought it might be related to Spotlight indices, since I've often noticed that spotlight has to re-index after a reboot. However, after spotlight appears to finish indexing (as reported in the spotlight menu), the available disk space is still over 10 gigs. So it's likely not spotlight.

The amount of space I get back is suspiciously close to the amount of RAM I have in my machine (8 gigs). Could it be related to virtual memory?

My assumption is that somehow it's related to temporary cache files, but I don't know which or why, or how to clear those caches without a reboot.

So my question is: Why do I get back 8 to 10 gigs of storage space after a reboot when my hard drive runs low on space?

Best Answer

When the OS is low on memory it creates a file called a swap file, aka virtual memory on your hard drive, and in OS X this starts at some amount (I think 64 MB) then double as needed. So if you have 8 GB of RAM, you could end up with an 8 GB swap file. This is then deleted when you reboot.

You can read about it on http://en.wikipedia.org/wiki/Paging

Where the files are located and how to disable it: http://osxdaily.com/2010/10/08/mac-virtual-memory-swap/