[MacOS] file descriptor와 process limit 늘리기

맥에서 “too many open files” 에러 나면서 안되는 경우가 있다. Linux에 비해 limits이 너무 적기 때문이다.

Big sur 기준

  1. sudo vi /Library/LaunchDaemons/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>524288</string>
      <string>524288</string>
    </array>
    <key>RunAtLoad</key>
    <true/>
    <key>ServiceIPC</key>
    <false/>
  </dict>
</plist>

2. sudo launchctl load -w /Library/LaunchDaemons/limit.maxfiles.plist

3. sudo vi /Library/LaunchDaemons/limit.maxproc.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.maxproc</string>
      <key>ProgramArguments</key>
        <array>
          <string>launchctl</string>
          <string>limit</string>
          <string>maxproc</string>
          <string>2048</string>
          <string>2048</string>
        </array>
      <key>RunAtLoad</key>
        <true />
      <key>ServiceIPC</key>
        <false />
    </dict>
  </plist>

4. sudo launchctl load -w /Library/LaunchDaemons/limit.maxproc.plist

5. sudo sysctl -w kern.maxfiles=5242880

6. sudo sysctl -w kern.maxfilesperproc=524288

7. Reboot

참고: https://wilsonmar.github.io/maximum-limits/

One thought to “[MacOS] file descriptor와 process limit 늘리기”

  1. 많은 도움 되었습니다. 덕분에 오래된 맥프로에 새로운 일을 시킬 수 있게 되었습니다. 감사합니다.

답글 남기기

이메일 주소는 공개되지 않습니다. 필수 필드는 *로 표시됩니다