A macOS build machine reports its disk is nearly full, but deleting tens of gigabytes of files barely moves the free-space number. How do APFS snapshots explain this, and what actually releases the space?
answer
- deleting is not freeing
- something still references those blocks
- hourly, and you never created them
- purgeable is not free
- thin the snapshots, not the files
basics
~20 sAPFS snapshots still reference the deleted files' blocks, so removing a file only unlinks it from the live volume and frees nothing. The space returns when the snapshots holding those blocks are thinned or deleted.
solid answer
~50 sThe files are gone from the live filesystem but their blocks are not free, because one or more **APFS snapshots** still reference them. A snapshot is a read-only, point-in-time image of the whole volume; APFS keeps it valid by never releasing a block any snapshot still points at. Deleting a file therefore just removes the live directory entry — the data stays pinned until every snapshot that saw it is gone. On a Mac the usual source is Time Machine's local snapshots, taken hourly on the Data volume whenever Time Machine is configured and retained for about a day; macOS also snapshots the system before an update so it can roll back. macOS reports the pinned space as *purgeable* rather than free, which is why Finder and `df` seem to disagree. The fix is to let the system thin the snapshots or to delete them explicitly with `tmutil`; simply deleting more files does nothing.
code
bash · 2 linestmutil listlocalsnapshots /System/Volumes/Data
tmutil thinlocalsnapshots /System/Volumes/Data 20000000000 4go deeper
Know that macOS keeps automatic point-in-time snapshots, and that files you delete can still be held by them, so free space does not always return right away.
Explain the mechanism: copy-on-write frees a block only when its last reference goes, snapshots are reference-holders, and macOS reports the pinned space as purgeable rather than free.
Diagnose it. Reason from 'space did not return' to 'something still references those blocks', list the volume's snapshots, thin them, and address the churn that makes a build host generate them faster than they age out.
Own the policy: decide whether hourly local snapshots belong on high-churn build hosts at all, and design capacity alerting on genuinely free blocks rather than on the purgeable-inclusive figure users see.
## Why deleting files can free nothing APFS is copy-on-write, so a block is never overwritten in place and a block is only returned to the container's free pool when *nothing* references it any more. A **snapshot** is a reference-holder: a read-only, point-in-time image of an entire volume, created almost instantly because it does not copy data — it just pins the volume's object map so every block reachable at that moment stays reachable. That is the whole explanation for the symptom. Deleting a 40 GB folder removes its entries from the live volume's tree, but if an hour-old snapshot still contains those files, the blocks remain referenced and cannot be freed. From the user's point of view the disk "refuses" to give the space back. ## Where the snapshots come from on a Mac Nobody creates these by hand, which is exactly why the symptom is confusing. **Time Machine local snapshots.** When Time Machine is configured, macOS takes a snapshot of the Data volume roughly hourly, keeps them for about 24 hours, and thins them automatically when free space runs low. They exist so you can restore recent files with the backup disk absent. **System updates.** macOS snapshots the system before installing an update, which is what makes an interrupted or bad update reversible. **Backup and imaging tools.** Third-party backup software commonly snapshots a volume to get a consistent view while copying it, and a crashed run can leave the snapshot behind indefinitely. On a CI machine, all three sources compound: churn is enormous, files are created and deleted constantly, and every hourly snapshot preserves a full generation of build output that the live volume no longer has. ## Purgeable space, and the disagreeing numbers macOS classifies snapshot-pinned blocks as **purgeable** — space the system believes it can reclaim on demand by thinning snapshots — and folds it into the "available" figure surfaced in Finder's storage view. Traditional tools that ask the filesystem for genuinely free blocks see the smaller, honest number. Hence the classic report: the Storage pane claims plenty of room while a build fails on ENOSPC, or `df` and Finder differ by tens of gigabytes. The practical reading: *free* means allocatable right now; *purgeable* means allocatable only after something is deleted first. ## Inspecting and releasing Snapshots on a mount point are listed and managed through Time Machine's tool: ```bash tmutil listlocalsnapshots /System/Volumes/Data tmutil thinlocalsnapshots /System/Volumes/Data 20000000000 4 ``` `thinlocalsnapshots` asks the system to delete snapshots until roughly the requested number of bytes has been reclaimed; the trailing urgency argument controls how aggressively it does so. `deletelocalsnapshots` removes a specific one by its timestamp. Space returns only as each snapshot goes away and its last reference on each block disappears — so removing the oldest snapshot may free little if a newer one saw the same data. A subtlety worth stating in an interview: the automatic thinning is *reactive*. It fires under space pressure, and a workload that allocates faster than the thinner reclaims can still hit ENOSPC despite gigabytes of purgeable space. ## The same mechanism is a feature Do not present snapshots purely as a hazard. The properties that pin your space are exactly what make macOS's system updates safely reversible, what lets Time Machine capture a consistent image of a live volume without quiescing it, and what lets the running system boot from a read-only snapshot of the sealed System volume. A snapshot costs nothing when taken and grows only as the live volume diverges from it — the cost is proportional to churn, which is why a CI machine feels it and a lightly used laptop does not. ## Diagnosing this in the field The reasoning chain an interviewer wants: 1. Free space did not move after deleting files, so something still references those blocks. 2. On APFS the reference-holders are snapshots and clones. 3. List the volume's snapshots and compare their ages with the deletions. 4. If the pinned space is snapshot-held, thin or delete the snapshots rather than hunting for more files to remove. 5. Prevent recurrence: bound the churn, or reconsider running Time Machine on a machine that rewrites its whole working set every hour. ## The one-line version On a copy-on-write filesystem, deleting a file is not the same as freeing its blocks. Space comes back when the last reference goes — and on macOS the last reference is usually an hourly snapshot you never asked for.
- Why does taking an APFS snapshot of a 400 GB volume finish instantly and cost almost nothing?Because no data is copied. The snapshot pins the volume's object map at that instant, so every block currently reachable stays reachable; only a small amount of metadata is written. Cost accrues afterwards and in proportion to churn: as the live volume overwrites or deletes data, the old blocks cannot be freed while the snapshot references them, so a quiet volume's snapshot stays nearly free and a busy one's grows fast.
- You delete the oldest snapshot and only a little space comes back. Why?Because a block is freed only when its last reference disappears. If a newer snapshot also captured that data — anything that existed across both points in time — the blocks stay pinned by the newer one. You get meaningful reclamation only for data that was unique to the snapshot you removed, which is why thinning often has to remove several before free space visibly moves.
- What distinguishes purgeable space from free space on macOS?Free space is allocatable immediately; purgeable space is currently held by something reclaimable — chiefly snapshots and cached content — and only becomes usable after macOS deletes that holder. Finder's availability figure includes purgeable space, while a filesystem-level query reports genuinely free blocks. The gap explains the classic mismatch, and it also means a burst of writes can fail before the reclaim keeps up.
- Are snapshots a backup?No. A snapshot lives inside the same container on the same device, so it protects against accidental deletion and bad updates but not against disk failure, theft, or a container-level corruption. It is a rollback point, and it is a useful source *for* a backup — a consistent view to copy from — but a backup has to leave the machine.
saying these in an interview costs you the question
- Assumes deleting a file always frees its blocks immediately
- Treats purgeable space as space available right now
- Says the disk is lying or the free-space number is a bug
- Keeps deleting more files instead of listing snapshots
- Calls local snapshots a backup of the machine