How do I increase "ulimit -u" (max user processes)? 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?
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.