# DRb throws Errno::EMFILE "Too many open files" with 256 conn

**URL:** <https://www.ruby-forum.com/t/drb-throws-errno-emfile-too-many-open-files-with-256-conn/110596>\
**Category:** Ruby\
**Created:** [July 27, 2007, 10:45pm UTC](https://www.ruby-forum.com/t/drb-throws-errno-emfile-too-many-open-files-with-256-conn/110596 "2007-07-27T22:45:53Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![unknown](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/u/4bbf92/32.png) [@unknown](https://www.ruby-forum.com/u/unknown)\
**Post date:** [July 27, 2007, 10:45pm UTC](https://www.ruby-forum.com/t/drb-throws-errno-emfile-too-many-open-files-with-256-conn/110596/1 "2007-07-27T22:45:53Z")

</div>

Hi,

I have a ruby / DRb process that is quiting with Errno::EMFILE every  
time it reaches 256 connections. This happens regardless of what I set  
in ulimit -n and only on Solaris.

/opt/csw/lib/ruby/1.8/drb/drb.rb:944:in `accept': Too many open files (Errno::EMFILE) from /opt/csw/lib/ruby/1.8/drb/drb.rb:944:in`accept’  
from /opt/csw/lib/ruby/1.8/drb/drb.rb:1581:in `main_loop' from /opt/csw/lib/ruby/1.8/drb/drb.rb:1430:in`run’  
from /opt/csw/lib/ruby/1.8/drb/drb.rb:1427:in `start' from /opt/csw/lib/ruby/1.8/drb/drb.rb:1427:in`run’  
from /opt/csw/lib/ruby/1.8/drb/drb.rb:1347:in `initialize' from /opt/csw/lib/ruby/1.8/drb/drb.rb:1627:in`new’  
from /opt/csw/lib/ruby/1.8/drb/drb.rb:1627:in `start\_service’  
from ./tuple\_space.sh:10

I also tried this test both in OSX and Solaris:

255.times {a\<\<File.open("/etc/hosts")}

and I got it working on OSX with a ulimit -n 2048 but it seems that  
Ruby on Solaris does not change its behavior based on ulimit -n and it  
still throws:

Errno::EMFILE: Too many open files - /etc/hosts  
from (irb):17:in `initialize' from (irb):17:in`open’  
from (irb):17  
from (irb):17:in `times’  
from (irb):17

Anyone has any insight on how to get Solaris to open more than 256  
files?

Thanks in advance.

---

<div class="post-metadata">

**Author:** ![unknown](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/u/4bbf92/32.png) [@unknown](https://www.ruby-forum.com/u/unknown)\
**Post date:** [July 28, 2007, 11:40am UTC](https://www.ruby-forum.com/t/drb-throws-errno-emfile-too-many-open-files-with-256-conn/110596/2 "2007-07-28T11:40:55Z")

</div>

As it turns out, I was having this problem until your post made me  
realize that it was solaris (and not my program, as I had assumed).  
Some research turn this up:

> **[Oracle Java Technologies | Oracle](https://www.oracle.com/java/technologies/)**
>
> Java can help reduce costs, drive innovation, & improve application services; the #1 programming language for IoT, enterprise architecture, and cloud computing.

which says that 32-bit applications are limited to 256 file  
descriptors when running under Solaris, unless you do the following:

export LD\_PRELOAD\_32=/usr/lib/extendedFILE.so.1

before running your program. Ruby on Solaris is a 32 bit app (we’ve  
never had it compile cleanly as a 64 bit application), so this makes  
sense. Except for the part about the limit of 256 file descriptors.  
But oh well!

cheers,

b.

---

<div class="post-metadata">

**Author:** ![unknown](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/u/4bbf92/32.png) [@unknown](https://www.ruby-forum.com/u/unknown)\
**Post date:** [August 1, 2007, 4:11am UTC](https://www.ruby-forum.com/t/drb-throws-errno-emfile-too-many-open-files-with-256-conn/110596/3 "2007-08-01T04:11:09Z")

</div>

On Jul 28, 6:38 am, Blaine C. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> > Hi,  
> > from /opt/csw/lib/ruby/1.8/drb/drb.rb:1427:in `start’  
> > and I got it working on OSX with a ulimit -n 2048 but it seems that  
> > Anyone has any insight on how to get Solaris to open more than 256  
> > files?
> 
> > Thanks in advance.

Thanks Blaine, … this works !!.
