5

I wanted to increase the limit on the number of open files on Windows 7 (64-bit). Using Git Bash for my command line environment, I enter the following command:

$ ulimit -n 9999

However, I encounter the following error:

bash: ulimit: open files: cannot modify limit: Too many open files

I would appreciate if you could help me with this problem. Thank you in advance for your assistance.

mklement0
  • 382,024
  • 64
  • 607
  • 775
datinfo
  • 51
  • 1
  • 3

1 Answers1

6

You're trying to set a limit that is too high.

As of the Git Bash that comes with Bash version 4.3.42(5)-release, the limit appears to be 3200:

$ ulimit -n 3200  # 3200 is the max. as of Git Bash 4.3.42(5)-release

This shell command determines the highest number you can pass to ulimit -n:

$ for n in {9999..255}; do ulimit -n $n 2>/dev/null &&  echo $n && break; done
3200

Note that you cannot lower the limit again, once you've set it to a certain number in a given session.

mklement0
  • 382,024
  • 64
  • 607
  • 775
  • Thank you for your response. The actual value that I need for my project is 5185 files. However, it appears that even this number is too high for the given 3200 limit. If I were to change my command line environment on Windows 7 from Git Bash to Windows shell, would it be possible to make such adjustment so that the limit for number of open files would match 5185 or greater? – datinfo Feb 29 '16 at 04:31
  • You can try MinGW/MSYS, whose Bash - though much older - at least _accepts_ much higher numbers with `ulimit -n` - whether that many files are then actually _supported_, I don't know. If running from the Windows shell (`cmd.exe`) is really an option - are your tools native Windows applications? - then, yes, it sounds like you have more than enough handles available there, according to [this](https://blogs.technet.microsoft.com/markrussinovich/2009/09/29/pushing-the-limits-of-windows-handles/). – mklement0 Feb 29 '16 at 05:21