Is there a fix for the "Too many open files in system" error on OS X 10.7.1?
Solution 1:
According to this helpful article (which I recommend reading):
By default, the maximum number of files that Mac OS X can open is set to 12,288 and the maximum number of files a given process can open is 10,240.
You can check these with:
sysctl kern.maxfiles
sysctl kern.maxfilesperproc
You can increase the limits (at your own risk) with:
-
sysctl -w kern.maxfiles=20480
(or whatever number you choose) -
sysctl -w kern.maxfilesperproc=18000
(or whatever number you choose)
To make the change permanent, use sudo
to put your settings in /etc/sysctl.conf
(which you may have to create), like this:
kern.maxfiles=20480
kern.maxfilesperproc=18000
Note: In OS X 10.10 or lower, you can add setting in /etc/launchd.conf
like limit maxfiles
and it will override whatever you put here.
Again, from the article:
Once you’ve done this, the kernel itself will have a maximum number of files but the shell might not. And since most processes that will take up this many files are going to be initiated by the shell you’re gonna want to increase that.
The command for that is:
ulimit -S -n 2048 # or whatever number you choose
That change is also temporary; it only lasts for the current shell session. You can add it to your shell configuration file (.bashrc
, .zshrc
or whatever) if you want it to run every time you open a shell.
Solution 2:
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.
Create a file at /Library/LaunchDaemons/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