8

This is an old problem, but again, none of the old solutions work anymore.

Default ulimit is far too low and I need to increase it to basically unlimited (like let's say a million).

And I need to increase it globally. Not just in the shell, so .zshrc-based solutions won't work; notably they won't apply to docker.

Increasing it in launchctl doesn't seem to persist it (and does it even do anything?)

(and yes, I now there's a lot of existing answers to this - but they only work on older OSX; I don't know if there's any "close as no longer working" function)

1
  • 2
    There's no 'close as no longer working' button because older macOS versions are still used, so the solutions are still relevant. Commented Jan 9, 2023 at 14:05

2 Answers 2

2

Increasing it in launchctl doesn't seem to persist it (and does it even do anything?)

If you need the ulimit modification to a specific launch daemon/agent, then you could try adding this to your .plist file (which works for me on Ventura)

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>

...

  <key>HardResourceLimits</key>
  <dict>
    <key>NumberOfFiles</key>
    <integer>64000</integer>
  </dict>
  <key>SoftResourceLimits</key>
  <dict>
    <key>NumberOfFiles</key>
    <integer>64000</integer>
  </dict>

...

</dict>
</plist>
1

Here are working steps. It requires 4 restarts. Old methods do not work:

  • boot into recovery mode - shut down the computer, press power button and keep holding it until Options appear, select Options, Continue
  • open Terminal from menu and run: csrutil clear
  • restart and return to the recovery mode like before
  • open Terminal from menu and run: csrutil disable
  • restart again (nto normal mode
  • create /Library/LaunchDaemons/limit.maxfiles.plist, following insturctions from this post (contents also copied below)
  • restart again, you finally have correct maxfiles limit globally

Here's what should be in limit.maxfiles.plist:

<?xml version="1.0" encoding="UTF-8"?> 
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" 
 "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0"> 
 <dict>
 <key>Label</key>
 <string>limit.maxfiles</string>
 <key>ProgramArguments</key>
 <array>
 <string>launchctl</string>
 <string>limit</string>
 <string>maxfiles</string>
 <string>64000</string>
 <string>524288</string>
 </array>
 <key>RunAtLoad</key>
 <true/>
 <key>ServiceIPC</key>
 <false/>
 </dict>
</plist>
3
  • Interestingly, the default value for sysctl kern.maxfiles in Ventura is 245760, and maxfilesperproc is 122880. Number of processes is 5333. That's up from the 256 files and 709 processes in Sierra, claimed by your linked article.
    – benwiggy
    Commented Feb 8, 2023 at 17:26
  • Shouldn't you enable csrutil enable again after creating the file?
    – sgmonda
    Commented Apr 18, 2023 at 5:45
  • 1
    This no longer works in Ventura 13.4.1 :(. sysctl kern.maxfiles still show 65535 :( Commented Aug 15, 2023 at 21:17

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .