---
title: "Finding Which Process Is Filling Your Mac's Disk"
url: https://deallocatedobjects.com/posts/finding-which-process-is-filling-your-macs-disk
author: Jake Marsh
published: 2026-11-23
updated: 2026-11-23
topics: ["Apple", "Xcode & Tools"]
description: "When free space on a Mac keeps going down, the usual move is to go looking for big files. If something is still writing to the disk, I want to know what it is before I start deleting anything. The kernel already keeps a count of bytes written for every process."
---

# Finding Which Process Is Filling Your Mac's Disk

By Jake Marsh, November 23, 2026. HTML: https://deallocatedobjects.com/posts/finding-which-process-is-filling-your-macs-disk

When free space on a Mac keeps going down, the usual move is to go looking for big files. If something is still writing to the disk, I want to know what it is before I start deleting anything.

The kernel already keeps a count of bytes written for every process. You can read it for your own processes without `sudo`, sample it twice, and get a list of who's writing and how fast. On my Mac the writer turned out to be iCloud, which I wrote about in [Why du Overcounts On APFS](https://deallocatedobjects.com/posts/why-du-overcounts-on-apfs). This post is the technique for finding that kind of thing.

### The Counter

`proc_pid_rusage()` in `libproc.h` fills in a `rusage_info` struct for a process. Since `RUSAGE_INFO_V2` that struct has a field called `ri_diskio_byteswritten`. I ask for `RUSAGE_INFO_V4`, which also has `ri_logical_writes`.

Before trusting it I checked the units. A test program wrote 64 MiB to a file and read its own counter before and after:

```text
after write(): diskio_written +58720256 logical +73424896
after fsync(): diskio_written +67108864 logical +74203136
64 MiB = 67108864
```

So it's bytes, and after the `fsync` it matches the file exactly. Most of the data had already been flushed by the time `write()` returned, and the rest landed with the `fsync`, all of it charged to the process that wrote it. `ri_logical_writes` came out about 10% higher in the same test, so I stick with `ri_diskio_byteswritten`.

The counter is cumulative from the moment the process started. `cloudd` on my Mac started on November 7 and, six days later, reads 50,259,709,952 bytes written. That's a useful number on its own (50 GB for a daemon I never think about), but it can't tell you whether `cloudd` is writing right now. For that you sample twice and subtract.

### What You Can Read Without sudo

I ran it against every pid on the Mac to see what comes back. Out of 1,391 processes, every one owned by my user worked, including zombies. The 295 owned by root or by system users like `_rmd` and `nobody` failed with `EPERM` (Operation not permitted). `proc_name()` returns an empty string for those too.

That's less of a limit than it sounds. `cloudd`, `bird`, `fileproviderd` and `Finder` all run as me, so the iCloud and file provider daemons, browsers, build tools and anything you started yourself are all visible. Root daemons like `launchd` aren't, and neither is Spotlight's `mds_stores`, which runs as its own `_mds_stores` user. If the list comes back quiet while the disk is still filling, remember it can't see those, and that's when I'd reach for the root-only tools at the end of this post.

### The Tool

It takes a snapshot of every process it can read, sleeps, takes another, and prints the biggest differences:

```swift title="disk-writers.swift"
import Foundation

// Lists the processes that wrote the most to disk over an interval.
// Usage: disk-writers [seconds]

struct Sample { var name: String; var written: UInt64 }

func allPIDs() -> [pid_t] {
    let count = proc_listallpids(nil, 0)
    var pids = [pid_t](repeating: 0, count: Int(count) + 64)
    let n = proc_listallpids(&pids, Int32(pids.count * MemoryLayout<pid_t>.size))
    return Array(pids.prefix(Int(max(n, 0))))
}

func bytesWritten(_ pid: pid_t) -> UInt64? {
    var info = rusage_info_v4()
    let result = withUnsafeMutablePointer(to: &info) {
        $0.withMemoryRebound(to: rusage_info_t?.self, capacity: 1) {
            proc_pid_rusage(pid, RUSAGE_INFO_V4, $0)
        }
    }
    return result == 0 ? info.ri_diskio_byteswritten : nil
}

func name(_ pid: pid_t) -> String {
    var buffer = [CChar](repeating: 0, count: 256)
    proc_name(pid, &buffer, UInt32(buffer.count))
    return String(cString: buffer)
}

func snapshot() -> (samples: [pid_t: Sample], denied: Int) {
    var samples: [pid_t: Sample] = [:]
    var denied = 0
    for pid in allPIDs() where pid > 0 {
        if let written = bytesWritten(pid) {
            samples[pid] = Sample(name: name(pid), written: written)
        } else {
            denied += 1
        }
    }
    return (samples, denied)
}

let seconds = CommandLine.arguments.dropFirst().first.flatMap { UInt32($0) } ?? 10
let before = snapshot()
sleep(seconds)
let after = snapshot()

// Counters are cumulative since each process started, so diff the two
// samples. A pid missing from the first sample started during the window.
let rows = after.samples.compactMap { pid, sample -> (pid_t, String, UInt64)? in
    let start = before.samples[pid]?.written ?? 0
    return sample.written > start ? (pid, sample.name, sample.written - start) : nil
}.sorted { $0.2 > $1.2 }

func megabytes(_ bytes: UInt64) -> String {
    String(format: "%9.1f MB", Double(bytes) / 1_048_576)
}

print("Top disk writers over \(seconds) s (\(after.denied) processes not readable)")
for (pid, name, bytes) in rows.prefix(10) {
    let rate = String(format: "%6.1f MB/s", Double(bytes) / 1_048_576 / Double(seconds))
    print("\(megabytes(bytes))  \(rate)  \(pid)\t\(name)")
}
```

`swift disk-writers.swift` works, but it compiles every time, so I build it once with `swiftc -O disk-writers.swift -o disk-writers`. To check the rate math I started a small Bun script that writes 10 MiB and calls `fsync` once a second, then ran the tool for 15 seconds:

```bash
$ ./disk-writers 15
Top disk writers over 15 s (298 processes not readable)
    140.0 MB     9.3 MB/s  26004	bun
     45.3 MB     3.0 MB/s  21434	bun
      1.6 MB     0.1 MB/s  46072	chrome_crashpad_handler
      0.6 MB     0.0 MB/s  21834	rsync
```

The first row is the test script: 14 writes of 10 MiB in the window. The second is another Bun process that happened to be busy. A 20 second run with nothing like that going on put Chrome at the top with 1.3 MB, which is what a quiet Mac looks like.

Two things it won't catch. A process that starts and exits inside the window is gone before the second snapshot, so a burst of short-lived `dd` or `cp` commands shows up as nothing. And `proc_name` cuts long names short, which is why you'll see things like `com.apple.Virtualization.Virtua`.

### When It's iCloud

`cloudd` is the CloudKit daemon and `bird` is one of the daemons behind iCloud Drive, and their man pages don't say much more than that. When my disk was dropping, `cloudd` was the top writer at about 1.1 GB a minute, putting back files that macOS had evicted.

`brctl status` shows what iCloud Drive still has to sync or write to disk. Its help text describes it as printing "items which haven't been completely synced up / applied to disk". On my Mac right now there's nothing waiting, so all it prints is the container's state:

```bash
$ brctl status com.apple.CloudDocs
1 containers matching 'com.apple.CloudDocs'
<c{1}m.a{3}e.C{7}s[1] foreground {client:idle server:full-sync|fetched-recents|fetched-favorites|ever-full-sync sync:oob-sync-ack last-sync:2026-11-12 01:17:21.175, requestID:136920, caught-up, token:... }>

Desktop & Documents: current=NO lastEnabled=(never) lastDisabled=(never)
```

`caught-up` and `client:idle` are what you want to see. When iCloud has work pending, those items are what the command is there to list. On this Mac it printed that right away and then took 45 seconds to exit, so don't wait on it in a script.

### What's Built In

Activity Monitor's Disk tab has a Bytes Written column you can sort by. It's the quickest place to look if you don't want to build anything.

`fs_usage` prints file system calls as they happen and can be limited to one process by pid or name, which is the next step once you know which process to look at. It refuses to run without root (`'fs_usage' must be run as root...`). `iotop` is still in `/usr/bin`, but it's a DTrace script, and on my Mac it stopped at "DTrace requires additional privileges" and warned that with System Integrity Protection on, some features won't be available.

What I like about the counter is how cheap it is. Reading it for all 1,447 processes on this Mac took 13 milliseconds, and nothing about it touches the files themselves.
