Take the 2-minute tour ×
Ask Different is a question and answer site for power users of Apple hardware and software. It's 100% free, no registration required.

I can change all of the usual ulimits via (for instance) ulimit -n 8192 and launchctl limit maxfiles 8192 8192. Somehow, this doesn't seem to work for -u, the maximum number of user processes:

~$ sudo launchctl limit maxproc 8192 8192
~$ sudo launchctl limit maxproc
    maxproc     2048           2048
-- in a new terminal:
~$ ulimit -u
1064

I do get a "failed to fork" every once in a while, and it's quite annoying having to kill a bunch of processes when "kill" can't start :) (i.e. I usually resort to just rebooting the machine).

What's the correct way to change the maximum number of user processes?

share|improve this question

1 Answer 1

http://blog.ghostinthemachines.com/2010/01/19/mac-os-x-fork-resource-temporarily-unavailable/ talks about this issue in great detail.

When you do sudo launchctl limit maxproc, you're viewing or changing the system-wide launchd limits.

When you do launchctl limit maxproc, you're viewing or changing the launchd limits for your user.

One thing to keep in mind is this:

The root user can increase the hard limits of the system-wide launchd, without a reboot. However, you cannot change a user’s launchd hard limits without a reboot (even if trying to do so as the root user).

Basically, the hard limit (the right hand column) that is displayed when you initially do launchctl limit maxproc will be the limit that you can set using ulimit -u without rebooting. Logging out and back in will not work. Even if you change whats displayed by launchctl limit maxproc, the initial hard limit remains. See this answer for a bit more info on the relationship between ulimit and launchctl limit. To raise that limit, you have to

  • edit/create /etc/sysctl.conf to raise the maximum processes supported by the kernel

    kern.maxproc=2500
    kern.maxprocperuid=2500
    
  • edit/create /etc/launchd.conf to raise the hard limits of the system-wide launchd at boot time

    limit maxproc 2500 2500
    
  • reboot

Also note that 2500 seems to be the maximum limit that kern.maxproc can be set to. I'll ask a question about this as soon as I reboot and have enough free processes to open another Chrome tab.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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