Ruby:打开的文件太多@rb_sysopen [英] Ruby: Too many open files @ rb_sysopen

查看:50
本文介绍了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_sysopen的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆