cachegrind.out Filled My Drive

I have a 1TB hard drive, but I'm not really using much of it, so when I started getting warnings about my disk space filling up, I was confused. I went and got Disk Inventory X to see what was using all this space. I found this:

Disk Inventory X Screenshot showing space taken by cachegrind.out.* files

That big blue field is a whole bunch of cachegrind.out files in /private/var/tmp.  Turns out these files are generated when you have Xdebug enabled, which I do because it's useful to debug PHP as a developer. So, first thing I try to do is delete all these useless files.

bash-3.2# rm -Rf /private/var/cachegrind.out.*
bash: /bin/rm: Argument list too long

ummm.  That's a lot of files! Here's the way to do it one at a time:

find /private/var/tmp -name "cachegrind*" -exec rm -rf {} \;

Of course this needs to be run as root or with sudo.

Removing the files brings me back to a working state. However it doesn't solve the problem that these files will just start accumulating again. Doing a little research I found that /var/tmp (or on Mac OS X /private/var/tmp) doesn't get cleared out as often as /tmp does. So I changed where Xdebug saves it's cache files to /tmp in my php.ini file. In my case with MacPorts it's at /opt/local/etc/php54/php.ini. I add the following in the configuration around where I enabled Xdebug:

xdebug.profiler_output_dir = "/tmp"

Restart apache and things seem to be working well. Net result: saving over 800 GB of disk space.