In Mac OS X, how can I get an accurate count of file descriptor usage?

I came across the need for identifying this recently – the command I used to count up the total entries (so more than just file handles, but it’s relative so therefore relevant in my opinion) is:

lsof | awk '{print $1}' | sort | uniq -c | sort -rn | head

This gives something like the following output (your highest-used applications may be different!):

$lsof | awk '{print $1}' | sort | uniq -c | sort -rn | head
1259 Google
 682 Code\x20H
 369 Spotify
 334 VLC
 322 cloudd
 303 corespotl
 278 com.apple
 273 UserEvent
 249 GitHub
 176 Slack\x20

I usually only need to see the top 10 entries, but you can manipulate head to show as many lines as you like (e.g., head -n 40).

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)