Skip to content

Commit 634d3fa

Browse files
antonvozniaPaul Hohensee
authored andcommitted
8351359: OperatingSystemMXBean: values from getCpuLoad and getProcessCpuLoad are stale after 24.8 days (Windows)
Backport-of: 900b3ff7ee933520efe2438fb7c841a4e6a93d17
1 parent ce312b3 commit 634d3fa

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

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

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2003, 2022, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2003, 2025, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -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
/*
@@ -993,7 +995,7 @@ bindPdhFunctionPointers(HMODULE h) {
993995
*/
994996
static int
995997
getPerformanceData(UpdateQueryP query, HCOUNTER c, PDH_FMT_COUNTERVALUE* value, DWORD format) {
996-
clock_t now = clock();
998+
uint64_t now = GetTickCount64();
997999

9981000
/*
9991001
* Need to limit how often we update the query

0 commit comments

Comments
 (0)