Mac – Increase the maximum number of open file descriptors in Snow Leopard

file-descriptorsmacosx-snow-leopardulimit

I am trying to do something that requires a large number of file descriptors

sudo ulimit -n 12288 is as high as Snow Leopard wants to go; beyond this results in

/usr/bin/ulimit: line 4: ulimit: open files: cannot modify limit: Invalid argument.

I want to raise the number much higher, say 100000. Is it possible?

Best Answer

Using ulimit command only changes the resource limits for the current shell and its children and sudo ulimit creates a root shell, adjusts its limits, and then exits (thus having, as far as I can see, no real effect).
To exceed 12288, you need to adjust the kernel's kern.maxfiles and kern.maxfilesperproc parameters, and also (at least according to this blog entry, which is a summary of this discussion) a launchd limit. You can use launchctl limit to adjust all of these at once:

sudo launchctl limit maxfiles 1000000 1000000

To make this permanent (i.e not reset when you reboot), create /etc/launchd.conf containing:

limit maxfiles 1000000 1000000

Then you can use ulimit (but without the sudo) to adjust your process limit.

If this doesn't do it, you may be running into size limits in the kernel. If your model supports it, booting the kernel in 64-bit mode may help.