Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[macOS] 设置最大文件打开数量 #21

Open
yangruihan opened this issue Nov 30, 2020 · 0 comments
Open

[macOS] 设置最大文件打开数量 #21

yangruihan opened this issue Nov 30, 2020 · 0 comments

Comments

@yangruihan
Copy link
Owner

yangruihan commented Nov 30, 2020

设置最大文件打开数量

问题描述

当使用git lfs拉取大量文件代码仓库时,出现了too many open files报错,导致拉取失败

解决方法

可以使用ulimit -a来查看当前电脑最大打开文件数量

-t: cpu time (seconds)              unlimited
-f: file size (blocks)              unlimited
-d: data seg size (kbytes)          unlimited
-s: stack size (kbytes)             8192
-c: core file size (blocks)         0
-v: address space (kbytes)          unlimited
-l: locked-in-memory size (kbytes)  unlimited
-u: processes                       2784
-n: file descriptors                256

可以看到-n: file descriptors 256,默认最大文件数量非常小

使用ulimit -n 1024来将最大文件数量扩大

如果提示权限不足,则需要在命令前加上sudo

如果ulimit -n xxxxxxx过大的话,会出现ulimit: open files: cannot modify limit: Invalid argument错误

这时需要使用如下命令来将其上限扩大:

sysctl -w kern.maxfiles=1024000

sysctl -w kern.maxfilesperproc=1024000

ulimit -n 1024000

设置完毕后问题得到解决

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant