Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I need to get rid of the pesky "Too many open files in system" limit on OS X 10.7.1. 

Is there a way?

share|improve this question
3  
Do you want to explain more about when this happens? In which circumstances? –  slhck Jun 7 '12 at 8:56
    
@slhck - I have the same problem. The circumstances are basically "at random." I'm a developer, so I'm using my Mac fairly heavily: running one or more databases, a web server, testing tools, one or more browsers, and a music player all at once. Google Chrome seems to be one program that has a lot of files open. –  Nathan Long Jun 22 '12 at 18:25
    
Actually, my "heavy use" wasn't the issue; my settings for the maximum number of open files for the kernal and per-process were far lower than what the defaults should be. –  Nathan Long Jun 29 '12 at 20:16
1  
If your read Nathan's comment and wondered why he didn't include any details about the defaults, it's because he spelled it all out in his answer, below. (Nice answer! :) –  Olie Jun 13 '13 at 18:06

3 Answers 3

Folks, on Mavericks 10.9.4

ulimit -n 2048 works fine. You may need to launch a new login session.

share|improve this answer

According to this helpful article (which I recommend reading):

By default, the maximum number of files that Mac OS X can open is set to 12,288 and the maximum number of files a given process can open is 10,240.

You can check these with:

  • sysctl kern.maxfiles
  • sysctl kern.maxfilesperproc

You can increase the limits (at your own risk) with:

  • sysctl -w kern.maxfiles=20480 (or whatever number you choose)
  • sysctl -w kern.maxfilesperproc=18000 (or whatever number you choose)

To make the change permanent, use sudo to put your settings in /etc/sysctl.conf (which you may have to create), like this:

kern.maxfiles=20480 
kern.maxfilesperproc=18000

(Note: a setting in /etc/launchd.conf like limit maxfiles will override whatever you put here.)

Again, from the article:

Once you’ve done this, the kernel itself will have a maximum number of files but the shell might not. And since most processes that will take up this many files are going to be initiated by the shell you’re gonna’ want to increase that.

The command for that is:

ulimit -S -n 2048 # or whatever number you choose

That change is also temporary; it only lasts for the current shell session. You can add it to your shell configuration file (.bashrc, .zshrc or whatever) if you want it to run every time you open a shell.

share|improve this answer
    
what limit applies to processes launched by clicking icons in the launch area? And how to change that limit? When you say "shell", I'm assuming you mean an interactive terminal shell. –  Cheeso Aug 15 '12 at 0:48
    
@Cheeso - I think that the overall system limit (sysctl) or the launchd limit, whichever is lower, controls that. –  Nathan Long Dec 14 '12 at 20:39
1  
creating an /etc/launchd.conf with contents limit maxfiles 1000000 1000000 worked great for me! (OSX 10.8.2 here) –  Zugwalt Feb 1 '13 at 19:26
    
@Zugwalt, what is the actual text you put inside the /etc/lunchd.conf? You can use ticks ( ` ) to escape code. –  Xeoncross Jun 28 at 0:59

You will need to increase your ulimit settings - it's pretty low on OS X these days - 256 by default. Add ulimit -n 4096 or similar to your ~/.profile or equivalent and that will solve it in your local environment. Run ulimit -a to check your current levels

To see the system settings, run this:

launchctl limit maxfiles

It is set quite a bit higher in Lion (10240) on a per process basis than it used to be. But if you are still hitting it there then you can set it higher using the same command with the desired levels. To make the changes permanent /etc/launchd.conf is where you need to add the relevant lines.

share|improve this answer
1  
256? It's 2560 file descriptors for me and I've never changed it. The limit is 266 processes (c.f. ulimit -a). –  slhck Jun 22 '12 at 18:55
    
@slhck it says open files (-n) 256 for me too, not 2560 –  Erik Aigner May 25 '13 at 10:43
    
Which version of OS X are you running? –  nealmcb May 26 at 18:19
    
Same for me, 256 files on MacOS X Maverick –  Climbatize Aug 9 at 6:44

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.