mac上解決Resource temporarily unavailable


Resource temporarily unavailable這種問題一般是因為當前的進程數或者文件數不夠

fork: Resource temporarily unavailable

修改最大進程數

我們可以通過ulimit -a來查看當前系統的一些系統參數。

 

在上面這些參數中,通常我們關注得比較多的是一個進程可打開的最大文件數,即open files
系統允許創建的最大進程數量即是max user processes 這個參數。

maxproc表示的是開啟的最大進程數,第一個1064表示的是soft限制,第二個1064表示的是hard限制,即硬件最大的限制數,自己設置的不能高於hard限制。所以 我soft也改成了1064最大的。

maxfiles表示的是開啟的最大文件數(句柄),意義同上……

修改的方式如下

打開或者新建一個文件:/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>65536</string>

          <string>65536</string>

        </array>

      <key>RunAtLoad</key>

        <true/>

      <key>ServiceIPC</key>

        <false/>

    </dict>

  </plist>

保存並重啟mac即可設置最大文件數。

打開或者新建一個文件:/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>

保存並重啟mac即可設置最大進程數。


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM