Macbook's harddrive free space changes seemingly randomly
Checking the space

You can use OmniDiskSweeper to check what is occupied your space. It's free.

Or, if you like command-line, run Terminal.app and enter this:

du -kx /some/directory | sort -nr &gt; $HOME/DiskUsage.txt
less $HOME/DiskUsage.txt


you will get sorted size-list (in kB) for all directories under the /some/directory.

Swap files

Another check - swap file. If your apps take more memory as you have, the OS do "swap" parts of memory into HDD. (In the linux or FreeBSD there are usually dedicated HDD partitions (slices) but on OS X these are files.

You can check their size with:

ls -l /private/var/vm


you will get something like the next:

total 12582912
-rw------T  1 root  wheel  4294967296 23 jún 14:30 sleepimage
-rw-------  1 root  wheel    67108864 15 jún 09:03 swapfile0
-rw-------  1 root  wheel    67108864 23 jún 14:54 swapfile1
-rw-------  1 root  wheel   134217728 23 jún 14:54 swapfile2
-rw-------  1 root  wheel   268435456 23 jún 14:54 swapfile3
-rw-------  1 root  wheel   536870912 23 jún 14:54 swapfile4
-rw-------  1 root  wheel  1073741824 23 jún 14:54 swapfile5


As you can see, in my HDD are now 5 swapfiles with total size 2GB. When start too much programs (or have 50 browser windows or soo) sometimes the swap increases up 5 GB or more. Simply close applications and the swap will be freed.

The another 4GB file (sleepimage) is the space, where OS X store its memory content when going to sleep (SafeSleep - storing memory content in the file). While it is possible turn of the SafeSleep and get 4GB HDD space (or less, if you have less memory) via pmset command, i do not recommend this.

Browser

When you browsing a lot, Safari storing some content into his cache/files. You can partially clear from the menu: Safari -> Empty Cache

Or simply check your cache files in the $HOME/Library/Caches with the OmniDiskSweeper or the du -kx $HOME/Library/Caches | sort -nr command from the Terminal.

You can Trash everything from the $HOME/Library/Caches without problems, but (for the safe) is better relog or reboot after the delete.

Logfiles

Another space-waste can be the Logfiles. You can check them with your Console.app (Utilities). (in the bottom left corner it showing the current size) - You can trash a big ones from the application directly.