Skip to content

Instruments trace files are huge, and nothing ever deletes them

A profiling session can produce a multi gigabyte trace. Where they are saved and which ones are worth keeping.

4 min read

Profiling records every sample, every allocation and every event for the duration of a run, which means a two minute Instruments session on a busy app can produce a trace measured in gigabytes. Traces are saved as documents and stay wherever they were saved.

Find them

find ~ -name '*.trace' -exec du -sh {} + 2>/dev/null | sort -h | tail -20
du -sh ~/Library/Developer/Xcode/Products 2>/dev/null

They accumulate in three places: wherever you chose to save them, in the default documents location, and in temporary locations for sessions that were never saved and never cleaned up.

What makes a trace large

  • Instrument choice. Allocations and Time Profiler at a high sampling rate produce the biggest files.
  • Duration. Size scales roughly linearly with how long you recorded.
  • Deferred mode. Recording without live display gathers more data, which is the point and the cost.
  • Symbolication data. Included so the trace is readable later, which is why it is worth keeping deliberately.

Which to keep

TraceKeep?
A baseline before an optimisationYes, until the work ships
The run that proved a regressionYes, attach it to the issue
Exploratory runs from a sessionNo
Anything older than the release it relates toNo

The habit worth having

Save traces into the project folder rather than accepting the default location, and delete them with the branch. A trace is only meaningful alongside the build it came from, so keeping one for a version that has since shipped rarely helps anyone.

Traces sit alongside the other Xcode folders that grow, and the full sequence is in DerivedData, archives and device support and simulator runtimes, which together are usually far larger.

Common questions

Where are Instruments trace files stored?

Wherever you saved them, plus the default documents location and temporary locations for unsaved sessions. A find for .trace files across your home folder locates all of them.

Why are Instruments traces so large?

Because they record every sample and event for the duration of the run, along with symbolication data so the trace stays readable. Allocations and high frequency time profiling produce the largest files.

Is it safe to delete .trace files?

Yes. They are recorded output, not part of your project, and a new profiling run replaces them. Keep the ones attached to an open issue or a baseline you are still comparing against.

How do I keep trace files under control?

Save them into the project folder rather than the default location, and delete them along with the branch. A trace is only meaningful alongside the build it came from.

Read next