How to find out number of files currently open by Java application?

后端 未结 5 1751
北恋
北恋 2020-12-13 09:01

Suppose a lot of what your application does deals with reading contents of files. It goes without saying that files that are opened then closed and life is good unless ... n

5条回答
  •  星月不相逢
    2020-12-13 09:19

    Sorry for necroposting, but guys, you're ignoring -K option of lsof cause java have threads, each of them have their own FD that are living in /proc/$PID/tasks/fd/

    and there is A HUGE difference:

    root@xxx:/root# lsof -p 13553 | wc -l
    612
    root@xxx:/root# lsof -p 13553 -K | wc -l
    112108
    

提交回复
热议问题