If you have a single program that is hitting a ulimit
(a soft limit on the number of files a single process can open), the adjusting the ulimit
to a higher number is fine, especially if you can just put the ulimit
command in your .bash_profile
. Beyond that, I strongly advise against editing files like /etc/launchd.conf
or /etc/sysctl.conf
or adding plist files under /Library/LaunchDaemons/
for a few reasons.
Changes to those files persist in backups, and are carried over to new versions of macOS and new computers when you upgrade.
If those changes cause problems (which is a real possibility), you have to remember that you made the changes and what the changes are and then re-edit the files to undo them. This can happen years later.
After a few years of upgrading, you may find that what used to be an increase in a limit is now a decrease in a limit. But you probably will not know that because you (a) will not remember that you made the change and (b) will not get to see the new limits because you overrode them from the start.
A Much Better Option
In general, rather than tuning individual parameters on the system and throwing the system out of balance (and potentially letting a single program crash the system by taking up all the resources), if the default system limits are insufficient for your needs, I recommend turing on "Server Performance Mode", or at least giving it a try. All you need for this is OS X / macOS 10.8 Mountain Lion or later and at least 16 GiB of memory installed. Early on you had to pay for this, but starting with OS X 10.8 Mountain Lion, it is free and officially supported by Apple with the standard OS.
Turning on this mode dramatically increases system limits, particularly the number of processes you can run and the number of files you can have open, at the cost of allocating more memory to the system kernel. You can read in detail what is changed by server performance mode in the answer to the question "What does serverperfmode=1 actually do on macOS?".
This mode has several advantages over editing configuration files as suggested by other answers.
- It is a change of a single parameter, easy to undo.
- It results in a balanced set of higher limits, preserving safeguards against rogue processes crashing the system.
- In most cases, it provides higher limits than the kernel would otherwise allow, even with editing configuration files.
- It raises default limits for all processes without any additional configuration changes.
- Starting with OS X 10.11 El Capitan, the configuration change is stored in NVRAM, which means if it is causing problems, you will revert to normal mode when you take the troubleshooting step of resetting NVRAM. You don't have to remember it.
- Because it is in NVRAM, it will not accidentally change state when restoring from backups.
- Because it is in NVRAM, it will not automatically come on when you clone your Mac setup to new hardware.
- Because it is officially supported by Apple, "it just works" and you will not get complaints from Apple Geniuses that you improperly modified the system when you ask for support.
- Because it is a change of a single parameter, you can easily turn it on and off for troubleshooting or comparison of one setting to the other.
Turn Server Performance Mode On or Off
To turn on Server Performance Mode, use the Terminal to run one of these commands and then reboot for it to take effect:
- For OS X 10.11 El Capitan or later, turn it on with
sudo nvram boot-args="serverperfmode=1 $(nvram boot-args 2>/dev/null | cut -f 2-)"
and turn it off with
sudo nvram boot-args="$(nvram boot-args 2>/dev/null | sed -e $'s/boot-args\t//;s/serverperfmode=1//')"
The above commands are what Apple officially recommends, but there is actually a problem with them, which is that if you run the "turn on" command twice, you then have to run the "turn off" command twice to turn it off. So check to see if it is on or off after making a change by running
nvram boot-args
If the output includes "serverperfmode=1" then the setting is on, and if it does not, then the setting is off.
- For OS X 10.8 Mountain Lion, OS X 10.9 Mavericks, and OS X 10.10 Yosemite, turn server performance mode on with
serverinfo --setperfmode 1
and turn it off with
serverinfo --setperfmode 0
Check the setting with
serverinfo --perfmode
The setting will not take effect until after you reboot the system.
Checking To See If The Computer Is Currently Running In Server Performance Mode
Checking the setting will tell you whether it is set to take effect (or not) after rebooting. To test to see if it currently active (assuming you have followed my advice and not edited any configuration files that change the settings), run
sysctl kern.maxproc
It will give you a number that is the maximum number of processes the system will allow. If that number is a multiple of 532, then server performance mode is off. If it is a round number (a multiple of 2500), then server performance mode is on for the currently running system.
/etc/sysctl.conf
, not/etc/sysctrl.conf
. – Siu Ching Pong -Asuka Kenji- Aug 08 '15 at 15:02sudo serverinfo --setperfmode true
once to put your machine in "Server Performance Mode". Then, you have a "higher maximum", depending on you machine configuration. Please see my post at https://discussions.apple.com/thread/5166397 for details. For 10.10 (Yosemite), the mode is on by default (at least on my machine!). See my answer below. – Siu Ching Pong -Asuka Kenji- Aug 08 '15 at 15:19