This is a problem I ran into while working on my team, and for some reason the solution was a bit involved. It's possible I didn't find the right resources at first, possibly because there seem to be different solutions depending on which version of OS X you are running.
My problems came in a couple forms, 1 running all of the unit tests in our Ruby of Rails project may have been a lot. Our project includes about 322 unit and functional test files with about 102 gems in the bundle/gemset.
It may have also happened when say, switching rvm gemsets, trying to open the Rails console, especially if it worked before, and then I added/updated gems at all, or running some other form of rails/rvm generic or test command. Any of those things may need to load a lot of files such as the gems, and helped me reach that open file handle limit.
I will attempt to capture my notes here so that if you run into the same type of problem, you can solve it as well.
ulimit command use necessary.
With this current set-up, I thought I had restarted my computer, re-run the problematic task (full unit/functional test suite), and still encountered the same file handle maximum error.
I just looked into the usual terminal environment configuration files (
/etc/bashrc), and I don't see any
ulimit lines in there.
I thought that was required to have the settings take full effect, as I did it with those files set and ran the command in a terminal session to see the eventual success of the task, but I have been running the task after that point, having restarted my computer since then, without re-issuing the
ulimit command again, and it works now, so maybe it's not needed?
SuperUser - Increase the maximum number of open file descriptors in Snow Leopard?
- CLI (temporary)
sudo launchctl limit maxfiles 1000000 1000000
sudo ulimit -n 12288
ulimit -n 12288?
limit maxfiles 1000000 1000000
limit maxfiles 8192 20480
limit maxproc 1000 2000
ulimit -n 4096
- Notes (implicitly quoted) :
- Alas: "The /etc/launchd.conf file is no longer consulted for subcommands to run during early boot time; this functionality was removed for security considerations."
- You will need to restart for these changes to take effect.
- AFAIK you can no longer set limits to 'unlimited' under OS X.
launchctl maxfilesis bounded by
sysctl maxfiles, and therefore cannot exceed them.
sysctlseems to inherit
ulimitseems to inherit it's 'open files' value from
- You can set a custom ulimit within
~/.profile; while this isn't required, I've provided an example.
- Be cautious when setting any of these values to a very high number when compared with their default - the features exist stability/security. I've taken these example numbers that I believe to be reasonable, written on other websites.
Open files limit does not work as before in OSX Yosemite
sysctl -w kern.maxfiles=65000
- CLI (alternate answer)
Maximum number of open filehandles per process on OSX (and how to increase)
sysctl -w kern.maxfilesperproc=20000
How to persist ulimit settings in OSX Mavericks?
Right now I don't have any Windows instructions. I wonder if there is a similar problem in a pure-Windows environment, or the exact same problem when running in a *nix-like environment or interpreter such as Cygwin and Bash/Fish respectively.