本文介绍了Ruby:打开的文件太多@rb_sysopen的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
使用 File.new(big_file)(不关闭)打开文件 1016 次 (Ubuntu) 或 1017 次 (CentOS) 后,似乎有一个限制,它引发了:
After opening a file with File.new(big_file) (without closing it) 1016 times (Ubuntu) or 1017 times (CentOS), it seems there is a limit and it raises:
Too many open files @ rb_sysopen - big_file (Errno::EMFILE)有什么办法可以提高这个限制吗?
Is there any way to raise that limit?
在我的系统上,ulimit 设置为 unlimited.
On my systems, ulimit is set to unlimited.
推荐答案- EMFILE 在您的进程中打开的文件过多.
- ENFILE 在整个系统中打开的文件太多.
- EMFILE is too many files opened in your process.
- ENFILE is too many files opened in the entire system.
所以 Errno::EMFILE 是由于 ruby 进程打开了太多文件.这个限制大概设置为默认的1024 可以看到:
So Errno::EMFILE is due to the ruby process opening too many files. This limit is probably set to the default 1024 can be seen with:
$ulimit -n 1024代替:
$ulimit unlimited您可以使用此方法提高限制.
更多推荐
Ruby:打开的文件太多@rb
发布评论