7

There's an issue in Xcode 4.2, where Xcode will fill my boot drive with tens of GB of preamble.pch-****** files, someplace within /private/var/folders/.

Does anybody know how to prevent this from happening?

This means I have to manually empty these files every few hours (quitting/restarting Xcode if necessary), to prevent my boot drive from filling up. I'd (likely) rather revert to the old behavior than create some script or program to systematically remove these every hour, if possible.

Misc:

  • My builds do not use precompiled headers (it looks like these are being generated by Xcode's text editors, using Clang's code sense indexing).
  • Tens of GB is a lot for my boot partitions; I use several small partitions.

Thanks

justin
  • 104,054
  • 14
  • 179
  • 226
  • @Bavarious Yes, I have considered it, and I don't share my machines so it is something I could do if that seems like the lesser evil when I want to reenable indexing (worth a +1 if you want to leave it as an answer). I keep the the bootable partitions/volumes small, but I have other partitions/volumes with plenty of free space. – justin Oct 16 '11 at 06:27
  • @Bavarious excellent detective work :) that works to move that 138MB per minute growth to a larger volume. – justin Oct 16 '11 at 08:04
  • And this is worth [filing a radar](http://bugreport.apple.com) –  Oct 16 '11 at 08:23
  • Related more generic on clang side: https://github.com/clangd/clangd/issues/1007 – Ciro Santilli OurBigBook.com May 24 '23 at 10:37

2 Answers2

2

I’m no clang expert, but a quick glance at lib/Frontend/ASUnit.cpp reveals that GetPreamblePCHPath() will use the value of three environment variables — in order: TMPDIR, TEMP and TMP — before defaulting to /tmp as the location of preamble PCH files. One (not really ideal) solution is to set one of those variables to a directory residing in another volume.

  • thanks for getting to the bottom of this. I agree that it's not ideal (especially for people who work on shared systems), but it's better than linking (which crossed my mind) when disabling code sense is not an option. – justin Oct 16 '11 at 08:34
0

Disabling Xcode's code sense indexing is one way to work around this. Still, this is not always ideal, and I am open to other solutions.

Community
  • 1
  • 1
justin
  • 104,054
  • 14
  • 179
  • 226