jmx-dev RFR: 8350939: Revisit Windows PDH buffer size calculation for OperatingSystemMXBean

Kevin Walls kevinw at openjdk.org
Mon Mar 3 17:17:30 UTC 2025


Following on from JDK-8350820, which backed out the _snprintf to snprintf change (JDK-8336289) in OperatingSystemImpl.c on Windows, because the counter names were being truncated (so CPU monitoring was not possible).

This change moves to snprintf again, but the counter names are not truncated.

snprintf must need the null terminator to fit inside the buffer length given.  It does not, and snprintf truncates (and always add the null terminator).

-------------

Commit messages:
 - 8350939: Revisit Windows PDH buffer size calculation for OperatingSystemMXBean

Changes: https://git.openjdk.org/jdk/pull/23861/files
  Webrev: https://webrevs.openjdk.org/?repo=jdk&pr=23861&range=00
  Issue: https://bugs.openjdk.org/browse/JDK-8350939
  Stats: 41 lines in 1 file changed: 0 ins; 5 del; 36 mod
  Patch: https://git.openjdk.org/jdk/pull/23861.diff
  Fetch: git fetch https://git.openjdk.org/jdk.git pull/23861/head:pull/23861

PR: https://git.openjdk.org/jdk/pull/23861


More information about the jmx-dev mailing list