Recently I found that the free disk space of my Mac OS X (Yosemite) got very small, so I looked into why.
$ sudo du -sh /*
↓
$ sudo du -sh /private/*
↓
$ sudo du -sh /private/var/*
Finally I found that /private/var/tmp contained over 200GB files.
In /private/var/tmp there are many files whose name are such as cachegrind.out.50526.
It is said that these files are generated by Xdebug profiler.
Yes, I use Xdebug from MacPorts.
Xdebug is convenient because it shows stacktrace in error, enables stepping execution (but it needs Eclipse...), and so on.
Then I attempted to delete them with rm but an error occurred.
$ sudo rm cachegrind.out.*
-bash: sudo: Argument list too long
Because the files were too many, shell expansion for "*" caused Argument list too long error.
Therefore I deleted them using find -exec.
$ cd /private/var/tmp
$ sudo find . -name 'cachegrind.out.*' -maxdepth 1 -exec rm {} \;
I got about 200GB free space.
See below for details about find -exec.
Delete or grep the results of find
If this goes on, files will be generated and they will fill up my disk again. So I decided to modify Xdebug setting so that Xdebug profiler will generate output files not in /private/var/tmp but in /tmp directory.
(I also set trace output directory to /tmp)
They will be deleted on rebooting.
/opt/local/etc/php53/php.ini
Add xdebug.profiler_output_dir and xdebug.trace_output_dir.
[xdebug]
xdebug.profiler_enable=On
xdebug.remote_enable=On
xdebug.remote_host="localhost"
xdebug.remote_port=9000
xdebug.remote_handler="dbgp"
xdebug.idekey=ECLIPSE_DBGP
xdebug.profiler_output_dir=/tmp/ ; where the profiler output will be written to
xdebug.trace_output_dir=/tmp/ ; where the tracing files will be written to
Xdebug: Documentation.