java打开的文件过多_java – IOException:打开文件太多

我试图在Linux中的Jetty 7.0.1中运行的Java webapp中调试文件描述符泄漏。

由于打开的文件太多,请求开始失败时,该应用程序已经开始运行了一个月左右,而Jetty必须重新启动。

java.io.IOException: Cannot run program [external program]: java.io.IOException: error=24, Too many open files

at java.lang.ProcessBuilder.start(ProcessBuilder.java:459)

at java.lang.Runtime.exec(Runtime.java:593)

at org.apache.commons.exec.launcher.Java13CommandLauncher.exec(Java13CommandLauncher.java:58)

at org.apache.commons.exec.DefaultExecutor.launch(DefaultExecutor.java:246)

起初我以为这个问题是启动外部程序的代码,但是它使用的是commons-exec,我没有看到任何错误:

CommandLine command = new CommandLine("/path/to/command")

.addArgument("...");

ByteArrayOutputStream errorBuffer = new ByteArrayOutputStream();

Executor executor = new DefaultExecutor();

executor.setWatchdog(new ExecuteWatchdog(PROCESS_TIMEOUT));

executor.setStreamHandler(new PumpStreamHandler(null, errorBuffer));

try {

executor.execute(command);

} catch (ExecuteException executeException) {

if (executeException.getExitValue() == EXIT_CODE_TIMEOUT) {

throw new MyCommandException("timeout");

} else {

throw new MyCommandException(errorBuffer.toString("UTF-8"));

}

}

列出服务器上的打开文件我可以看到大量的FIFO:

# lsof -u jetty

...

java 524 jetty 218w FIFO 0,6 0t0 19404236 pipe

java 524 jetty 219r FIFO 0,6 0t0 19404008 pipe

java 524 jetty 220r FIFO 0,6 0t0 19404237 pipe

java 524 jetty 222r FIFO 0,6 0t0 19404238 pipe

当Jetty开始的时候只有10个FIFO,几天后就有数百个FIFO。

我知道在这个阶段有点模糊,但是您有什么建议可以在下一步看看,还是如何获得有关这些文件描述符的详细信息?

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值