← LOG/TECHNOLOGY/ENTRY N° 153

Hunting a coreaudiod port leak on macOS: what I found so far

macOS coreaudiod grew to 87 GB and over 10,000 Mach ports, then filled swap and the disk. This post covers the monitors I set up, how lsmp snapshots disproved my first theory and proved the leak is inside coreaudiod, and...

FILED
READ
4 MIN
CATEGORY
TECHNOLOGY
TAGS
MACOS · COREAUDIOD · MEMORY LEAK · MACH PORTS

Diagram: apps and USB audio connect to coreaudiod, whose port table fills with leaked ports until a restart clears it

On 2026-11-23 my Mac ran out of swap and then out of disk. The culprit was coreaudiod, the macOS audio daemon: 87 GB of memory and 10,539 Mach ports. I have not found the trigger yet, so this is a write-up of what I know so far, not a fix.

TL;DR

  1. Log coreaudiod memory and port count every minute, so the next blowup has evidence.
  2. Snapshot its ports with sudo lsmp -p <pid> and count the types.
  3. Leaked ports were semaphores and named-memory entries, and quitting apps or unplugging devices freed none of them.
  4. sudo killall coreaudiod cleared them, which proves the leak is inside the daemon.
  5. Until Apple fixes it: restart coreaudiod when ports climb, and file a Feedback report.

The symptom and the setup

By the time I noticed, macOS was warning about low disk space and everything was slow. Activity Monitor showed coreaudiod at 87 GB. A reboot cleared it, which left me with no evidence, so I set up two cheap monitors before the next occurrence.

Figure 0. Activity Monitor showing coreaudiod at 87.52 GB of memory and 10,539 ports

A logger that records memory and port count once a minute:

nohup zsh -c 'while true; do
  echo "$(date +%FT%T) $(top -l 1 -pid $(pgrep -x coreaudiod) -stats mem,ports | tail -1)" >> coreaudiod_mem.log
  sleep 60
done' >/dev/null 2>&1 &

And a watcher on the unified log for coreaudiod messages:

/usr/bin/log stream --predicate 'process == "coreaudiod"' >> coreaudiod_events.log

Two traps cost me time:

  • Use /usr/bin/log, not log. In zsh on macOS, log is a shell builtin that does something unrelated.
  • Monitors die on reboot. A reboot at 22:10 on the first day left a gap in my log. I now restart both by hand after any reboot.

What the data said

My first theory, after a few days of logs, was that the port count just tracked the number of connected audio clients. It was wrong.

The daily floor of the port count kept rising: about 890 on 2026-11-24 and about 2,135 on 2026-11-29, roughly +250 ports a day.

Figure 1. Daily port and memory floor of coreaudiod, rising in steps until the restart

The floor is the lowest port count (top) and memory (bottom) seen each day, from my per-minute log. Memory grows far less than ports: 18M to 23M. The 2026-11-29 value of 2,135 is the floor just before the restart. The chart skips 2026-11-23 because a reboot that evening reset the daemon.

To see what was growing I took snapshots of the daemon's ports. lsmp needs root, so it has to run in a real terminal where sudo can prompt:

sudo lsmp -p "$(pgrep -x coreaudiod)" > "lsmp-$(date +%F-%H%M%S).txt"

Counting the leaked types is one line:

grep -E '^0x' lsmp-*.txt | grep -oE 'SEMAPHORE|NAMED-MEMORY' | sort | uniq -c

Semaphores grew from 340 to 854 over five days (about +170 a day) and named-memory ports from 161 to 418. Both had an empty peer column, meaning no other process was on the other end.

Then I tried to free them by elimination. I quit seven clients one at a time, taking a snapshot after each, and unplugged two USB audio devices. The counts did not move. Lesson learned: name snapshot files with seconds (%H%M%S). A rerun within the same minute overwrote one of my snapshots.

The restart test, workarounds and open leads

The decisive test was restarting the daemon. macOS relaunches it automatically:

sudo killall coreaudiod

Figure 2. coreaudiod before and after the restart, line charts of ports and memory around the restart

The same numbers as a table:

Metric Before After
Total ports 2,141 836
Semaphores 854 18
Named-memory ports 418 0
Memory 26M 14M

Nothing outside the daemon was holding those ports, and a fresh process starts clean. The leak is inside coreaudiod, which is Apple code protected by SIP, so I can't patch it locally.

What I do in the meantime

  • Check the port count in my log and run sudo killall coreaudiod when it climbs well above the ~840 baseline. Audio drops for a moment and recovers.
  • Check for macOS updates, since a fix would ship that way.
  • File a report through Feedback Assistant with the snapshots attached.

What is still unsolved

The 87 GB figure is not explained by this leak. After 5.5 days it only reached about 27M of memory, so the blowup needs another cause. I have one unverified lead: a stream of audio overload reports in the unified log that started days earlier. I also have untested suspects around the USB audio chain and apps that play sounds. Next I'll watch the counts from the clean baseline and re-introduce each suspect one at a time, taking a snapshot after each step. I'll update this post when I know more.

A note on how this was debugged

I used an AI assistant to help plan the experiments and read the snapshots. I ran every command and checked every number on my own machine before writing it up.

References

■ END OF ENTRY 153