RFR: 8351359: OperatingSystemMXBean: values from getCpuLoad and getProcessCpuLoad are stale after 24.8 days (Windows)
Kevin Walls
kevinw at openjdk.org
Tue May 6 11:13:06 UTC 2025
OperatingSystemImpl.c on Windows is limited by its use of clock(), which hits its limit with longer process uptimes.
https://learn.microsoft.com/en-us/cpp/c-runtime-library/reference/clock?view=msvc-170
"maximum clock function return value of 2147483.647 seconds, or about 24.8 days"
The linked alternative, time(), gives 64-bit time but only seconds. In the example code for time(), there is use of _ftime() to retrieve milliseconds.
The example code also notes that _ftime is deprecated, so _ftime_s is used here.
-------------
Commit messages:
- 8351359: OperatingSystemMXBean stops reporting cpuLoad and processCpuLoad after 24.8 days
Changes: https://git.openjdk.org/jdk/pull/25062/files
Webrev: https://webrevs.openjdk.org/?repo=jdk&pr=25062&range=00
Issue: https://bugs.openjdk.org/browse/JDK-8351359
Stats: 8 lines in 1 file changed: 5 ins; 0 del; 3 mod
Patch: https://git.openjdk.org/jdk/pull/25062.diff
Fetch: git fetch https://git.openjdk.org/jdk.git pull/25062/head:pull/25062
PR: https://git.openjdk.org/jdk/pull/25062
More information about the serviceability-dev
mailing list