Skip to content

Instantly share code, notes, and snippets.

@nocash
Created February 26, 2016 17:08
Show Gist options
  • Save nocash/27b436f9f863ebc1b768 to your computer and use it in GitHub Desktop.
Save nocash/27b436f9f863ebc1b768 to your computer and use it in GitHub Desktop.
Adjusting Open File Limits in Yosemite

Band-aid fix for exceeding max open files limit on OSX.

http://docs.basho.com/riak/latest/ops/tuning/open-files-limit/#Mac-OS-X

To check the current limits on your Mac OS X system, run:

launchctl limit maxfiles

Files should be saved as /Library/LaunchDaemons/limit.maxfiles.plist and /Library/LaunchDaemons/limit.maxproc.plist.

Both plist files must be owned by root:wheel and have permissions -rw-r--r--. This permissions should be in place by default, but you can ensure that they are in place by running sudo chmod 644 <filename>. While the steps explained above will cause system-wide open file limits to be correctly set upon restart, you can apply them manually by running launchctl limit.

In addition to setting these limits at the system level, we recommend setting the at the session level as well by appending the following lines to your bashrc, bashprofile, or analogous file:

ulimit -n 65536
ulimit -u 2048
<?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>65536</string>
<string>65536</string>
</array>
<key>RunAtLoad</key>
<true/>
<key>ServiceIPC</key>
<false/>
</dict>
</plist>
<?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.maxproc</string>
<key>ProgramArguments</key>
<array>
<string>launchctl</string>
<string>limit</string>
<string>maxproc</string>
<string>2048</string>
<string>2048</string>
</array>
<key>RunAtLoad</key>
<true />
<key>ServiceIPC</key>
<false />
</dict>
</plist>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment