IOException:打开的文件太多 [英] IOException: Too many open files

查看:441
本文介绍了IOException:打开的文件太多的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在Linux上的Jetty 7.0.1中运行的Java Web应用程序中调试文件描述符泄漏.

I'm trying to debug a file descriptor leak in a Java webapp running in Jetty 7.0.1 on Linux.

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

The app had been happily running for a month or so when requests started to fail due to too many open files, and Jetty had to be restarted.

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 ,但我没有发现任何问题:

At first I thought the issue was with the code that launches the external program, but it's using commons-exec and I don't see anything wrong with it:

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:

Listing open files on the server I can see a high number of FIFOs:

# 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,几天后又有数百个.

when Jetty starts there are just 10 FIFOs, after a few days there are hundreds of them.

我知道在这个阶段有点模糊,但是您对下一个地方或如何获取有关这些文件描述符的更多详细信息有任何建议吗?

I know it's a bit vague at this stage, but do you have any suggestions on where to look next, or how to get more detailed info about those file descriptors?

推荐答案

您的外部程序无法正常运行.看看为什么它不这样做.

Your external program does not behave properly. Have a look at why it doesn't do that.

这篇关于IOException:打开的文件太多的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆