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