[PJUG Javamail] What causes "Too many open files" in Tomcat
Bob Dietrich
bob at processpath.com
Wed Nov 4 20:46:38 EST 2009
Of course, if this is a resource issue that normally takes a while to
encounter, you can set the ulimit *down* to 100 or so to see the problem
much more quickly.
Bob
From: Aaron Getz [mailto:getza1 at gmail.com]
Sent: Tuesday, November 03, 2009 6:00 PM
To: Creyf, Jo
Cc: Portland Java Users Group; Rob Tanner
Subject: Re: [PJUG Javamail] What causes "Too many open files" in Tomcat
I have also seen this issue before. The application was running in Tomcat
and was failing to close JDBC connections to the database. It, as Jo
mentions is a misleading error. I would look for code that is failing to
close connections. In my particular code it was in a loop so I was opening
a lot of connections very quickly and then failing to close any of them.
Aaron
On Tue, Nov 3, 2009 at 5:03 PM, Creyf, Jo <Jo.Creyf at nike.com> wrote:
I've seen this issue before where an application running in Tomcat was not
explicitly closing network sockets and was leaving handles in a CLOSE_WAIT
state.
The application was grabbing a new IP port each time and left previously
used ports in limbo land.
Note that this was not a Tomcat issue but more of a coding issue.
The issue was resolved by explicitly closing and cleaning up network
sockets.
The ulimit setting tells the operating system that each running process on
the machine can have up to that number of handles (file handles and network
handles). If the setting is 1024, then the Tomcat process can have up to
1024 files and network ports open. You'll get the "Too many open files" if
that number is reached and Tomcat tries to grab another file or network
handle.
The too many open files message may be confusing. I think it should
actually read "Too many open handles".
Your stack trace is showing java.net.SocketException, which leads me to
think that you too may be dealing with some code that is leaving network
handles open.
You may want to run lsof and probably grep for "CLOSE_WAIT" or grep for your
Tomcat's process id and monitor the output for a while to see what is eating
up your resources.
Good luck!
Jo Creyf
From: javamail-bounces at pjug.org [mailto:javamail-bounces at pjug.org] On Behalf
Of Rob Tanner
Sent: Tuesday, November 03, 2009 4:01 PM
To: Chris Foster
Cc: Portland Java Users Group
Subject: Re: [PJUG Javamail] What causes "Too many open files" in Tomcat
I thought about that but the problem isn't system wide. But thanks because
you've just reminded me that ulimit is shell specific although the default
of 1024 should certainly be sufficient. I've modified the catalina.sh start
up script to set ulimit to 4096 (ulimit -n 4096). That's definitely
overkill and if ulimit was the problem, I shouldn't see that error again.
I'll just need to keep an eye out.
Again thanks,
Rob
On 11/3/09 3:25 PM, "Chris Foster" <cjafoster at gmail.com> wrote:
Check your ulimit. Chances are the Linux (or unix) file limit is too low.
- Chris
On Nov 3, 2009, at 2:53 PM, Rob Tanner <rtanner at linfield.edu> wrote:
Hi,
I'm getting messages like these in the catalina.out log:
java.net.SocketException: Too many open files
java.io.FileNotFoundException: /usr/dict/wordlist.pwd (Too many open files)
java.io.FileNotFoundException:
/var/apache/apache-tomcat-5.5.23/webapps/AccountManager/WEB-INF/classes/log4
j.properties (Too many open files)
java.net.SocketException: Too many open files
And, of course, I have to stop and restart Tomcat to get it to work again.
This is not a system error; it's only in Tomcat. I did some googling and
found a suggestion with regard to Java arguments when Tomcat starts up.
These are the options I'm starting Tomcat with: '-XX:NewSize=128m
-XX:MaxNewSize=128m -XX:SurvivorRatio=8 -Xms256m -Xmx512m'
I've also gone through the most active apps and made sure that I was not
leaving any database or LDAP connections open.
Any ideas?
Thanks,
Rob
Rob Tanner
JAVA Developer
Linfield College, McMinnville Oregon
_______________________________________________
Web Site - http://www.pjug.org/ <http://www.pjug.org/>
Javamail mailing list
Javamail at pjug.org
http://www.pjug.org/mailman/listinfo/javamail
_____
_______________________________________________
Web Site - http://www.pjug.org/
Javamail mailing list
Javamail at pjug.org
http://www.pjug.org/mailman/listinfo/javamail
_______________________________________________
Web Site - http://www.pjug.org/
Javamail mailing list
Javamail at pjug.org
http://www.pjug.org/mailman/listinfo/javamail
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.pjug.org/pipermail/javamail/attachments/20091104/06f91e55/attachment.html
More information about the Javamail
mailing list