Too many open file handles

前端 未结 12 1509
误落风尘
误落风尘 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:51

    Not a direct answer to your question but these problems could be the result of releasing file resources incorrectly in your legacy code. By example if you're working with FileOutputsStream classes make sure the close methods are called in a finally block as in this example:

    FileOutputsStream out = null;
    try {
      //You're file handling code
    } catch (IOException e) {
      //Handle
    } finally {
      if (out != null) {
        try { out.close(): } catch (IOException e) { }
      }
    }
    

提交回复
热议问题