Open files limit does not work as before in OSX Yosemite [duplicate]

It seems like there is an entirely different method for changing the open files limit for each version of OS X!

For OS X Sierra (10.12.X) you need to:

  1. In /Library/LaunchDaemons create a file named limit.maxfiles.plist and paste the following in (feel free to change the two numbers, which are the soft and hard limits, respectively):

    <?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>64000</string>
            <string>524288</string>
          </array>
          <key>RunAtLoad</key>
          <true/>
          <key>ServiceIPC</key>
          <false/>
        </dict>
      </plist> 
    
  2. Change the owner of your new file:

    sudo chown root:wheel /Library/LaunchDaemons/limit.maxfiles.plist
    
  3. Load these new settings:

    sudo launchctl load -w /Library/LaunchDaemons/limit.maxfiles.plist
    
  4. Finally, check that the limits are correct:

    launchctl limit maxfiles
    

I see you asked this question all over.

There is a kernel limit you have to deal with, kern.maxfiles which is the kernel limit and can't be exceeded when setting ulimit.

See the Krypted blog page Maximum Files in Mac OS X for a description on how to manipulate kern.maxifiles using sysctl.

I haven't loaded Yosemite on my Mac yet. The sysctl -w kern.maxfiles=65000 works on Mavericks, which has the same kern.maxfiles=12288 limit by default.

I checked on my VM OS X 10.6.8 and it had the same limit which begs the question of how it was previously working prior to your OS X version.

There's a slide share (DB2 for Mac OS X Installing and setting up DB2 for Mac OS X) showing the recommended limits for using DB2, see Increase System Parameters page 7.

Increase System Parameters

Open /etc/sysctl.conf (or create it if it doesn't already exists) and insert the following settings. These settings increase some settings for shared memory and user limits that DB2 needs in order to work on Mac.

Add the following to /etc/sysctl.conf
kern.sysv.shmmax=1073741824
kern.sysv.shmmin=1
kern.sysv.shmmni=4096
kern.sysv.shmseg=32
kern.sysv.shmall=1179648
kern.maxfilesperproc=65536
kern.maxfiles=65536

It sounds like you lost your /etc/sysctl.conf file when you upgraded.


In Mac OS 10.10 it seems the ulimit setting can't exceed the launchctl limit setting.

So you should first run launchctl limit maxfiles in terminal to get the current setting:

launchctl limit maxfiles
maxfiles    256            unlimited 

So in my case the soft limit is 256, the hard limit is unlimited. And then if i want to set the soft limit to 512:

sudo launchctl limit maxfiles 512 unlimited

Detailed usage of launchctl for setting limits can be found here: https://developer.apple.com/library/mac/documentation/Darwin/Reference/ManPages/man1/launchctl.1.html