Coding, coding, coding....

Mac OS X - too many open files....

This is really annoying. Why something has to be simple if it can be complicated? For some reason on Mac OS X commands: 'ulimit' and 'sysctl' works fine but are actually useless. Don't count on them if you want to change maximum number of open files in your system. Fortunately this forum threads comes to help. To save you from reading through all of this here is how it goes: To check limits on your system run: 'launchctl limit'. To change max number of open files run: 'launchctl limit maxfiles 400000 unlimited'. To change the setting permanently add to the file: '/etc/launchd.conf' following line: limit maxfiles 400000 unlimited This doesn't however work for maxproc setting and please don't ask my why. I am asking...

This is really annoying. Why something has to be simple if it can be complicated?

For some reason on Mac OS X commands: 'ulimit' and 'sysctl' works fine but are actually useless. Don't count on them if you want to change maximum number of open files in your system. Fortunately this forum threads comes to help. To save you from reading through all of this here is how it goes:

To check limits on your system run: 'launchctl limit'. To change max number of open files run: 'launchctl limit maxfiles 400000 unlimited'. To change the setting permanently add to the file: '/etc/launchd.conf' following line:

limit maxfiles  400000           unlimited

This doesn't however work for maxproc setting and please don't ask my why. I am asking...

 

Comments

Info from year 2013 :) MacOS:

Info from year 2013 :)
MacOS: 10.8.3
For me it worked but only when I set both soft and hardlimit to the same value. And of course changes are visible after restart.

So my /etc/launchd.conf has line like below:

limit maxfiles 100000 100000

with empty line at the bottom.

Launchctl only applies to

Launchctl only applies to launch daemon. You need sysctl. =o

On 10.6 at any rate, I think

On 10.6 at any rate, I think you can't use unlimited and in fact it won't work unless you have the hard and soft limits the same. So you might as well leave off the fourth param (hard limit):

limit maxfiles 400000

The configuration below

The configuration below works on my OS X 10.5.6 box.
 
My system improved the most with the addition of maxfiles over any of the other tweaks I have made to OS X.
 
Also, you should look at increasing your OS X Shared Memory via /etc/sysctl.conf.  Apple has the default Shared Memory set to a paltry 4MB Apple.  Most Linux systems have to 32MB of Shared Memory
 
bash-3.2# more /etc/launchd.conf
limit maxproc 1024 2048
limit maxfiles 2048 unlimited
 
(NOTE: Sometimes configuration files must have 1 empty line at the end of the configuration)
 
bash-3.2# launchctl limit
cpu         unlimited      unlimited      
...
maxproc     1024           2048           
maxfiles    2048           unlimited
 
bash-3.2# uname -a
Darwin xxxxxxxx 9.6.0 Darwin Kernel Version 9.6.0: Mon Nov 24 17:37:00 PST 2008; root:xnu-1228.9.59~1/RELEASE_I386 i386

 

Please let me know if you're

Please let me know if you're looking for a article writer for your site. You have some really good posts and I feel I would be a good asset. If you ever want to take some of the load off, I'd absolutely love to write some content for
your blog in exchange for a link back to mine. Please shoot me an email if interested.
Cheers!

Doesn't work for me (Mac OS

Doesn't work for me (Mac OS 10.6.3). Set maxfiles in /etc/launchd.conf to 1024, but ulimit still reports 256 after reboot. Any idea why?

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.