Skip to content

Instantly share code, notes, and snippets.

@nweddle
Last active October 20, 2022 21:34
Show Gist options
  • Save nweddle/bd949e3a306736ac53f42a8a01c97f3d to your computer and use it in GitHub Desktop.
Save nweddle/bd949e3a306736ac53f42a8a01c97f3d to your computer and use it in GitHub Desktop.
Increase maxfiles limit on macOS Monterey 12.6
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>limit.maxfiles</string>
<key>ProgramArguments</key>
<array>
<string>launchctl</string>
<string>limit</string>
<string>maxfiles</string>
<string>32767</string>
<string>9223372036854775807</string>
</array>
<key>RunAtLoad</key>
<true />
<key>ServiceIPC</key>
<false />
</dict>
</plist>
@nweddle
Copy link
Author

nweddle commented Oct 20, 2022

References

https://apple.stackexchange.com/a/366319
https://gist.github.com/tombigel/d503800a282fcadbee14b537735d202c

32767 = maximum value for a signed 16-bit integer. Selected as a sane default. YMMV.
9223372036854775807 = maximum value for a signed 64-bit integer. Results in hard limit being set correctly to default of unlimited.

Check current limit values

launchctl limit maxfiles
ulimit -n

Default values for macOS Monterey 12.6 are maxfiles 256 unlimited

Steps to apply higher limit values

curl -O https://gist.githubusercontent.com/nweddle/bd949e3a306736ac53f42a8a01c97f3d/raw/2f0fc9dfc602797a83f9847dc73413de7c455f3c/limit.maxfiles.plist
sudo mv limit.maxfiles.plist /Library/LaunchDaemons/
sudo chown root:wheel /Library/LaunchDaemons/limit.maxfiles.plist
sudo launchctl load -w /Library/LaunchDaemons/limit.maxfiles.plist

In some cases a machine restart may be required for above to take effect.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment