Author Topic: How to modify the Open Files Limit on Macs  (Read 191 times)

0 Members and 1 Guest are viewing this topic.

Offline lordtyger

  • Babbling Baby
  • *
  • Posts: 13
  • Has not found this setting yet :)
How to modify the Open Files Limit on Macs
« on: April 12, 2017, 12:16:31 PM »
in Yosemite and Newer versions of the Mac OS the method used to modify the Open Files Limit Has Changed.
Use the instructions below:

Adjusting Open File Limits in Yosemite {and Later}.

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--.
These 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.

Easiest way to create the files limit.maxfiles.plist and limit.maxproc.plistis to just copy and paste the xml code into a text file and save with the correct name and file extension.


Note: Once you have made your plist files and placed them in Library/LaunchDaemons you Must change the owner and group for the two files. Also you need to make sure that the files have the correct permission settings.

Terminal commands to do this are:

sudo chown root:wheel <PathToFile>
sudo chmod 0644 <PathToFile>

Probably the easiest way to enter the <PathToFile> would be to type the commands followed by a space and then drag the file into the open Terminal window and hit return.

You will be asked for your admin password the first time and when you type it you won’t see any typing. Just hit return when you are finished entering it.

=*=*=*=*=*=*=*=*=

In addition to setting these limits at the system level, it is recommended, (but not required) that you set the limits at the session level as well by
appending the following lines to your bashrc, bashprofile, or analogous file:

Shell
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.

 

anything