Max open files per process

前端 未结 2 1417
有刺的猬
有刺的猬 2020-12-30 16:51

What is a maximum open files count in Mac OS X (10.6) per process?

ulimit said than 256, sysctl said 10240, but my test program can create 9469 (under gdb), 10252 (w

相关标签:
2条回答
  • 2020-12-30 16:54

    I came across a relevant error when running some python script on my mac. The error was complaining about the limit of open files.

    I was actually quite surprised to see ulimit -n telling me 256.

    If you end up here to fix this, next logical step is to increase the limit.

    How to increase that limit

    To complement the answer by Dmitry I will link the following gist with the solution (worked for me on Mac OSX Catalina).

    The linked above recipe will instruct you how to increase the limit.

    /Library/LaunchDaemons/limit.maxfiles.plist
    /Library/LaunchDaemons/limit.maxproc.plist
    

    After applying the load.sh and a system rebot, I got ulimit -n saying 524288. This has made by python script happy. GL!

    0 讨论(0)
  • 2020-12-30 17:18

    It is clear now.

    The ulimit command is build in shell. You can set the maxfiles using ulimit -n command for current shell (and every program which was started from this shell).

    10252 files - it was my mistake.. it was 253 max open files when I start my test program from shell (253 + stdin + stdout + stderr = 256).

    9469 files - the result of my test program running under Xcode, it seems that Xcode set tha maxfiles before running the program.

    ulimit is not system wide setting, thats why to set the system wide value for maxfiles you must use launchctl (the first process in the system, try to 'launchctl limit') or sysctl.

    And the answer is 256 files.

    0 讨论(0)
提交回复
热议问题