RFR: 8359706: Add file descriptor count and maximum limit to VM.info
Kieran Farrell
kfarrell at openjdk.org
Fri Oct 24 08:32:34 UTC 2025
Currently, it is only possible to read the number of open file descriptors of a Java process via the `UnixOperatingSystemMXBean` which is only accessible via JMX enabled tools. To improve servicability, it would be benifical to be able to view this information from jcmd VM.info output or hs_err_pid crash logs. This could help diagnose resource exhaustion and troubleshoot "too many open files" errors in Java processes on Unix platforms.
This PR adds reporting the current open file descriptor count to both jcmd VM.info output or hs_err_pid crash logs by refactoring the native JNI logic from `Java_com_sun_management_internal_OperatingSystemImpl_getOpenFileDescriptorCount0` of the `UnixOperatingSystemMXBean` into hotspot. Apple's API for retrieving open file descriptor count provides an array of the actual FDs to determine the count. To avoid using `malloc` to store this array in a potential signal handling context where stack space may be limited, the apple implementation instead allocates a fixed 32KB struct on the stack to store the open FDs and only reports the result if the struct is less than the max (1024 FDs). This should cover the majoirty of use cases.
-------------
Commit messages:
- clean up
- clean up
- undo commit to linux.cpp
- rm max count and malloc
- bsd.cpp
- update
- change to print outs
- replace NULL
- rm classloader
- rm files
- ... and 8 more: https://git.openjdk.org/jdk/compare/62f11cd4...2d2acfe4
Changes: https://git.openjdk.org/jdk/pull/27971/files
Webrev: https://webrevs.openjdk.org/?repo=jdk&pr=27971&range=00
Issue: https://bugs.openjdk.org/browse/JDK-8359706
Stats: 92 lines in 6 files changed: 92 ins; 0 del; 0 mod
Patch: https://git.openjdk.org/jdk/pull/27971.diff
Fetch: git fetch https://git.openjdk.org/jdk.git pull/27971/head:pull/27971
PR: https://git.openjdk.org/jdk/pull/27971
More information about the hotspot-dev
mailing list