Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Ruby: Too many open files @ rb_sysopen

Tags:

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?

On my systems, ulimit is set to unlimited.

like image 494
Victor Avatar asked Nov 14 '16 20:11

Victor


1 Answers

  • EMFILE is too many files opened in your process.
  • ENFILE is too many files opened in the entire system.

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

Instead of:

$ulimit
unlimited

You can raise the limit using this method.

like image 165
Victor Avatar answered Oct 02 '22 19:10

Victor