安泰信息

2006年12月06日

Too many open files

归档在: 未分类 — JACKEYJ @ 11:38 AM

env: centos 4.3 , jboss 4.0.3sp1 ,jdk1.5.6
在环境中部署了j2ee的应用.最近发现系统在运行一段时间之后就会出现too many open files的错误.
当这个错误出现之后.jboss就会挂起,里面部署的应用也会被undeploy掉.
java.net.SocketException: Too many open file

23:48:24,840 ERROR [PoolTcpEndpoint] Endpoint [SSL:

ServerSocket[addr=/0.0.0.0,port=0,localport=443]] ignored exception:

java.net.SocketException: Too many open files

java.net.SocketException: Too many open files

在google搜索发现是有可能是系统的df设置太小的缘故引起的.我们的系统内核的设置是默认的soft limit是1024.

目前的解决方法参考下面:

In linux you can increase this limit by giving
echo “65535″ > /proc/sys/fs/file-max. The default is 1024 which is
easily taken up in a medium scale application.

The possible reasons could be
- many database connections
- too many threads
- too many files are kept open
- heavy use of recursion/reflection

In unix, almost everything including sockets etc are treated
as files. This means that you have to check your code whether
you have closed the database connections, sockets, files etc.
One useful tool is lsof. This displays the list of open files
at any time. /proc/sys/fs/file-nr shows the information about
the total file handles allocated, free and used.

当然这个软限制无法突破硬限制.如果要进一步的增加,就需要重新编译内核,来提高硬限制的参数!

]]>

Powered by ZJANT