Monday, December 15, 2008

Jruby / Tomcat Too Many Open Files

For those plagued by the following error in Tomcat running JRuby

IOError (/usr/local/tomcat/webapps/myapp/WEB-INF/app/controllers/sessions_controller.rb (Too many open files)):

This is apparently a leak in <> should display your current max limit

Assuming your java pid is 1111, type "lsof +p 1111 | wc -l" and compare to the number above, it should almost certainly be higher than the limit.

To fix this on Redhat Linux edit the file /etc/security/limits.conf and add a line that looks like:

* - nofile 4096

To fix this on Solaris edit the file /etc/system and add a line that looks like:

set rlim_fd_cur = 4096
set rlim_fd_max = 4096

8 comments:

Su Ladâ said...

Thanks for the post. I always thought setting ulimit would solve it but it's currently set to unlimited. I'll try your solution. I don't get the error all the time, though.

Dberg said...

ulimit is only for the current user shell I believe, but does not affect all newly spawned system processes. I learned that one the hard way too :-)

for IT the said...

Great Article
Java Online Training | Java EE course

Java Training in Chennai | J2EE Training in Chennai | java j2ee training institutes in chennai ~ Java Course in Chennai | Java Training Institutes in Chennai

Java 360 | IT Technical Articles |Java Training Institutes

Addison adolf said...

We are offering design services in affordable price for your businesses and much more......

John Alert said...

I have read your blog its very attractive and impressive. I like it your blog.


JavaEE Training in Chennai JavaEE Training in Chennai

Java Training in Chennai Core Java Training in Chennai Core Java Training in Chennai

Java Online Training Java Online Training Core Java 8 Training in Chennai Java 8 Training in Chennai

John Alert said...

Java Training Institutes Java Training Institutes
Java Spring Hibernate Training Institutes in Chennai J2EE Training Institutes in Chennai J2EE Training Institutes in Chennai Java Spring Hibernate Training Institutes in Chennai | Hibernate Training Institutes in Chennai Core Java Training Institutes in Chennai Core Java Training Institutes in Chennai

Hibernate Online Training Hibernate Online Training Hibernate Training in Chennai Hibernate Training in Chennai Java Online Training Java Online Training Hibernate Training Institutes in ChennaiHibernate Training Institutes in Chennai

John Alert said...

JMS Training Institutes in Chennai JMS Training Institutes in Chennai | JSP Training Institutes in Chennai | Spring Training Institutes in Chennai Spring Training Institutes in ChennaiMicroServices Training Institutes In Chennai Java MicroServices Training Institutes In Chennai
Java EE Training Institutes in Chennai Java EE Training Institutes in Chennai

John Alert said...

Java Training InstitutesJava Training Institutes Java Training in Chennai | Java Training in Chennai | Dot Net Training in Chennai JavaScript Training in CHennai JavaScript Training in CHennai | | Single Page Application Development