Tips October 31, 2006 at 9:37 am

Increasing the Maximum Allowed Processes (ulimit) in 10.4

A quick tip on how to use launchd.conf to up some of your system limits.If you have ever seen log errors like this:

[Time 2006.10.27 13:16:39 UTC] [Facility user] [Sender ARDAgent ] [PID 184] [Message socket(PF_ROUTE) failed: Too many open files]

the solution is fairly simple. Increase the ulimit of your box.

Ulimit is a *nix term for the maximum number of processes allowed per user. You can see the normal limit in 10.4 by running the command

sudo launchctl limit

The value you are looking for is under the heading ‘maxproc’. It will look something like this:

hostname:~ user$ sudo launchctl limit
Password:
        cpu         unlimited      unlimited      
        filesize    unlimited      unlimited      
        data        6291456        unlimited      
        stack       8388608        67108864       
        core        0              unlimited      
        rss         unlimited      unlimited      
        memlock     unlimited      unlimited      
        maxproc     100            532            
        maxfiles    256            unlimited  

Note the default values of 100 (soft limit) and 532 (hard limit). If any user goes over 532 processes, bad things will happen. Remember that lots of system-level daemons have their own uid, so this doesn’t just apply to human users.

To up the limit, write an appropriate launchd.conf file. Launchd.conf contains launchctl commands that will be run when launchd starts, launchd being process number 1 on your system.

sudo echo "limit maxproc 200 1000" > /etc/launchd.conf

Ed. Note: The previous command assumes you don’t already have an existing launchd.conf. If you do already have the file it would probably best to just hand edit the file with your favorite text edtor.

Now restart the machine. When the system comes back up, launchd will adjust the maxproc/ulimit threshold according to what you’ve just set in the command above. Double-check by running:

sudo launchctl limit

You may need to do some benchmarking and monitoring to make sure that your new settings work properly. I’d suggest being conservative at first.

Lastly, note that you can set maxproc/ulimit for individual launchd items – consult the man page for launchd.plist for more info on the HardResourceLimits and NumberofProcesses keys.

No Comments

  • This line won’t work unless you’re already running as root:

    sudo echo "limit maxproc 200 1000" > /etc/launchd.conf

    since the shell redirection is processed prior to executing sudo. This would
    work if you just want to quickly cat a line to the file:

    sudo sh -c 'echo "limit maxproc 200 1000" >/etc/launchd.conf'

Leave a reply

You must be logged in to post a comment.