# Increasing Yosemite maxfile limit for Application

daemonlaunchctllaunchdosx-yosemiteulimit

I've been trying to up the maxfile limit and maxfileperproc limit on Yosemite, with no luck. I have created a sysctl.conf file in the etc folder, which has successfully increased the values when displayed via grep.

However, if I look at launchctl limit maxfiles, the value is is still incorrect.

Some solutions appear to be using ulimit -n to set the limit, but when in terminal, I cannot actually use this. It gives me an error of "Invalid argument" or "Unauthorized operation". I have successfully increased ulimit through a bash_profile script, but since the application is run from Applications, not the shell, it is irrelevant. I also successfully increased ulimit through the root user, but when that is logged out, it doesn't save changes.

Ideally, I'm looking for something that works like the launchd.conf file did, and just increases launchctl limit maxfiles {#} automatically on reboot.

Is there a way to do this successfully? Maybe using a 3rd party like Lingon, or with a launch daemon?

Thanks!

I figured this out thanks to playing with Riak from Basho. The directions for Yosemite are:

To adjust open files limits on a system-wide basis in Mac OS X Yosemite, you must create two configuration files.

The first is a property list (aka plist) file in /Library/LaunchDaemons/limit.maxfiles.plist that contains the following XML configuration:

<?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>
<true/>
<key>ServiceIPC</key>
<false/>
</dict>
</plist>


This will set the open files limit to 65536. The second plist configuration file should be stored in /Library/LaunchDaemons/limit.maxproc.plist with the following contents:

<?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>
<true />
<key>ServiceIPC</key>
<false />
</dict>
</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


Like the plist files, your bashrc or similar file should have -rw-r--r-- permissions. At this point, you can restart your computer and enter ulimit -n into your terminal. If your system is configured correctly, you should see that maxfiles has been set to 65536.

The process is slightly different on other version of OS X, but also well documented by that team. Again, thanks are due to the team at Basho for documenting this process.