Java Code: How to get open File Descriptors / File Handles
By angsuman, Gaea News NetworkSunday, July 5, 2015
One of the mysterious reasons for hanging of a long running server is running out of file descriptors. While you can delay the problem by increasing file descriptor (also known as File handle) count, it will not solve the problem in most cases. Then you need to figure out which method is leaking the file descriptors or to begin with if that is even an issue. I will show you a simple one-line code to get File Descriptor count in Java:
java.lang.management.ManagementFactory.getOperatingSystemMXBean().getOpenFileDescriptorCount()
That’s it!
It has no dependency on any import nor does it require any third party library.
Like it? Subscribe to the Email newsletter or to the RSS feed.
YOUR VIEW POINT