开发者

Max open files per process

开发者 https://www.devze.com 2023-03-19 01:26 出处:网络
What is a maximum open files count in Mac OS X (10.6) per process? ulimit said than 256, sysctl said 10240, but my开发者_JAVA技巧 test program can create 9469 (under gdb), 10252 (without gdb) files..

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

ulimit said than 256, sysctl said 10240, but my开发者_JAVA技巧 test program can create 9469 (under gdb), 10252 (without gdb) files..


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.


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

精彩评论

暂无评论...
验证码 换一张
取 消