r/iOSProgramming • u/mikerCZX • 3h ago
Solved! My Mac mini lost 350 GB in a month. du couldn't see 280 GB of it. Here is what it was and how I found it
TL;DR: My Mac mini (M6, 1 TB, macOS 27, Xcode 27.2) went from ~500 GB free to ~150 GB in about a month. A user-level du explained only ~490 GB of the ~770 GB in use. The missing ~280 GB was mostly one root-only file, 237 GB: /System/Library/Caches/com.apple.coresymbolicationd/data. symbolscache status shows its size without root. Clearing it freed 237.7 GB.
How I got there (in the order that worked)
- Sample
df -k /System/Volumes/Datathree times, 15 s apart. That is the rate. Mine was still falling while my build and test jobs ran, so it was not an old pile. diskutil apfs listandtmutil listlocalsnapshots /: no local snapshots, no Time Machine, nothing there.du -xk -d1per top-level folder, in parallel. It added up to ~457 GiB. Careful with units: I divided by 1048576 (GiB) and compared withdiskutil(decimal GB), and "found" a 313 GB hole that was really ~280 GB. Same units on both sides first.- Something was invisible to my user. A one-off root probe found the file above: 237 GB,
drwx------ root, not SIP-protected, so neitherdunor any cleanup tool I ran ever listed it. symbolscache status(no root) printsbytes total: 220.85 GiB there.symbolscache --wide listlists only your own uid's entries (18 GB for me), so the rest belongs to other uids, probably root's from crash reports.
What I think fed it (partly proven, partly a hypothesis)
I run a Swift Testing suite with exit tests (#expect(processExitsWith: .failure)) that trap on a precondition on purpose. Each run wrote ~4 crash reports for swiftpm-testing-helper, and every new test build has a new binary UUID that CoreSymbolication caches. Unified log, last 12 h: ReportCrashService made 374 connections to coresymbolicationd, ReportMemoryException 52, spindump 16. Activity Monitor: 0, though it had been open for days. The cache is never compacted: symbolscache --help itself says it "cannot reliably recover space during deletes" and that you must use compact.
- Verified: a toy program that traps writes one crash report per run (3 runs, 3 reports); the same program with
signal(SIGTRAP) { _ in _exit(1) }(also SIGILL, SIGABRT) exits 1 and writes none. - Not proven: that the exit tests alone caused 237 GB. The cache refilled to 4.9 GB overnight even after I silenced them, from crashes of ordinary macOS services. So "the tests did it" is a hypothesis.
The fix
With root, once per uid that owns entries (I had uid 0 and 501): sudo symbolscache delete --uid <uid>, then a plain sudo symbolscache delete, then sudo symbolscache compact. Deleting alone does not give the space back. Used entries 12370 → 0, bytes total 221 GB → 912 KB, and df free went 202.3 → 440.0 GB. The file keeps its logical size (237 GB) but is allocated at 0.9 MB, which is why ls -l keeps lying and stat -f %b (allocated blocks) tells the truth.
I now run a nightly LaunchDaemon that reads symbolscache status, compacts above 30 GB, and mails me the result plus a CSV row per night. Measured after the fix: 20.98 GB (2 Dec), 25.63 (3 Dec), 26.72 (4 Dec). So it still grows, slowly, and I have not found what feeds it now.
The rest of the 350 GB (all of it legitimate, which is why it's easy to miss)
- Simulator runtimes: 41.6 GB under
/System/Library/AssetsV2(7 images, ~8 GB each). Not under~/Library, so a cleanup that walks the home folder never sees them.xcrun simctl runtime listshows them. - Parallel agent/CI worktrees, 9-14 GB each: DerivedData ~9 GB,
.build~2 GB, plus 2.9 GB of tracked screenshots every checkout carries. Seven of them at once is ~60-90 GB. - Test temp under
/private/var/folders/*/*/T**:** 27 GB ofTemporaryDirectory.*and friends once. - Cloned simulators for automated test personas: ~3 GB each, 19 GB in a day.
- 110 GB created in one day when everything ran at once (measured by file birth time in allocated blocks, 4.8 M files in 5 min). Free space swings 40-60 GB just from jobs in flight, so don't judge a single reading.
Traps that wasted my time
mdfind "kMDItemFSSize > ..."andlsofsizes are logical: cloud placeholders (Google Drive, OneDrive) and sparse files (Xcode's compilation cache: 24 GB logical, 0 allocated) look like the culprit. Readstat -f %b.- System Settings > Storage counts purgeable space as free. It said 451 GB available while
dfsaid 203 GB free. I first blamed the cache for that gap and was wrong: after the clear the 248 GB gap was identical to the megabyte. I still don't know what it is. Trustdf -k /System/Volumes/Dataanddiskutil apfs list. find ... -deletecannot remove a directory like*.xcresult; userm -rf <path>.
Questions for you
- Has anyone seen
coresymbolicationdgrow like this without a test suite that crashes on purpose? - Does anyone know what the ~248 GB gap between Settings and
dfactually is on macOS 27?
