Troubleshooting 'Too many files open' with lsof

最后都变了- 提交于 2019-12-02 23:52:02

Definition

  • java - The process with the open file.
  • 25426 - This should be the real PID. If not please let us know what it is by posting the header.
  • 420 w - The file descriptor number followed by the mode it was opened with. (Read / write)
  • 0,8 - Major minor device identification.
  • 273664482 - The inode of the file.
  • pipe - A FIFO pipe that is open in your application.

Interpretation

You are not closing all your streams. There are many open file descriptors in read or write mode that are writing to un-named pipes. The most common scenario for this to happen, is when folks use Runtime.getRuntime.exec() and then proceed to keep the streams associated with the process open. You can use the commons IO utils library to close them or you can close them yourself.

    try
    {
        p = Runtime.getRuntime().exec("something");
    }
    finally
    {
        if (p != null)
        {
            IOUtils.closeQuietly(p.getOutputStream());
            IOUtils.closeQuietly(p.getInputStream());
            IOUtils.closeQuietly(p.getErrorStream());
        }
    }

If that is not the problem, you'll need to dig into your code base and identify where the leaky streams are and plug them.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!