5

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!

8

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>
      <key>RunAtLoad</key>
        <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>
      <key>RunAtLoad</key>
        <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.

  • Just went through this and I can confirm it works (10.10.2), but there are a couple notes: 1) a restart is required. running launchctl limit didn't work for me, 2) Those two ulimit commands fail prior to a restart (and I think are unnecesary?), I just ignored that part. – Cory Mawhorter Mar 31 '15 at 21:06
  • 1
    Based on my testing, the maximum permissible value for maxproc in Yosemite is 2500. "launchctl limit maxproc 2500" works, but any larger values are silently ignored. I'm sure this is in the documentation somewhere... – user443187 May 2 '15 at 5:14
  • @JLG Helpful to know. Given that the starting point seems to be 1064 on my MacPro, that's only x2.5, which is dismal compared with my hope of being able to get it up to 10-15k processes, to support 20-odd robot users running parallel iOS simulators. Looks like we're going to have to hunt up some of the older 8-core mac minis and bodge-cluster them. – android.weasel Dec 21 '15 at 16:35
  • Actually, that wasn't a mac pro - it was a mac pro booting from a mac mini pretending to be a hard drive. Maybe there's an actual server version of MacOs that can go higher? – android.weasel Dec 21 '15 at 16:51

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.