Too many open file handles

前端 未结 12 1505
误落风尘
误落风尘 2020-12-16 03:00

I\'m working on a huge legacy Java application, with a lot of handwritten stuff, which nowadays you\'d let a framework handle.

The problem I\'m facing right now is

12条回答
  •  被撕碎了的回忆
    2020-12-16 03:46

    To answer the second part of the question:

    what can cause open file handles to run out?

    Opening a lot of files, obviously, and then not closing them.

    The simplest scenario is that the references to whatever objects hold the native handles (e.g., FileInputStream) are thrown away before being closed, which means the files remain open until the objects are finalized.

    The other option is that the objects are stored somewhere and not closed. A heap dump might be able to tell you what lingers where (jmap and jhat are included in the JDK, or you can use jvisualvm if you want a GUI). You're probably interested in looking for objects owning FileDescriptors.

提交回复
热议问题