Resource temporarily unavailable这种问题一般是因为当前的进程数或者文件数不够

fork: Resource temporarily unavailable

修改最大进程数

我们可以通过ulimit -a来查看当前系统的一些系统参数。

 mac上解决Resource temporarily unavailable

在上面这些参数中,通常我们关注得比较多的是一个进程可打开的最大文件数,即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即可设置最大进程数。

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2021-10-11
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2021-12-11
  • 2022-02-22
  • 2021-10-06
  • 2022-02-02
  • 2021-12-30
相关资源
相似解决方案