Skip to content

Commit 900b3ff

Browse files
committed
8351359: OperatingSystemMXBean: values from getCpuLoad and getProcessCpuLoad are stale after 24.8 days (Windows)
Reviewed-by: amenkov, sspitsyn
1 parent ad07426 commit 900b3ff

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

src/jdk.management/windows/native/libmanagement_ext/OperatingSystemImpl.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,8 @@
5050
#include <process.h>
5151
#pragma warning(pop)
5252

53+
#include <sysinfoapi.h>
54+
5355
typedef unsigned __int32 juint;
5456
typedef unsigned __int64 julong;
5557

@@ -215,10 +217,10 @@ static PdhLookupPerfNameByIndexFunc PdhLookupPerfNameByIndex_i;
215217
*/
216218
typedef struct {
217219
HQUERY query;
218-
uint64_t lastUpdate; // Last time query was updated (ticks)
220+
uint64_t lastUpdate; // Last time query was updated (millis)
219221
} UpdateQueryS, *UpdateQueryP;
220222

221-
// Min time between query updates (ticks)
223+
// Min time between query updates (millis)
222224
static const int MIN_UPDATE_INTERVAL = 500;
223225

224226
/*
@@ -991,7 +993,7 @@ bindPdhFunctionPointers(HMODULE h) {
991993
*/
992994
static int
993995
getPerformanceData(UpdateQueryP query, HCOUNTER c, PDH_FMT_COUNTERVALUE* value, DWORD format) {
994-
clock_t now = clock();
996+
uint64_t now = GetTickCount64();
995997

996998
/*
997999
* Need to limit how often we update the query

0 commit comments

Comments
 (0)