Skip to content
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
8351359: OperatingSystemMXBean: values from getCpuLoad and getProcess…
…CpuLoad are stale after 24.8 days (Windows)

Reviewed-by: amenkov, sspitsyn
  • Loading branch information
kevinjwalls authored and antonvoznia committed Sep 22, 2025
commit f74f04181f90d7560c0a5cbb3dfa9068fb0ed391
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@
#include <process.h>
#pragma warning(pop)

#include <sysinfoapi.h>

typedef unsigned __int32 juint;
typedef unsigned __int64 julong;

Expand Down Expand Up @@ -215,10 +217,10 @@ static PdhLookupPerfNameByIndexFunc PdhLookupPerfNameByIndex_i;
*/
typedef struct {
HQUERY query;
uint64_t lastUpdate; // Last time query was updated (ticks)
uint64_t lastUpdate; // Last time query was updated (millis)
} UpdateQueryS, *UpdateQueryP;

// Min time between query updates (ticks)
// Min time between query updates (millis)
static const int MIN_UPDATE_INTERVAL = 500;

/*
Expand Down Expand Up @@ -993,7 +995,7 @@ bindPdhFunctionPointers(HMODULE h) {
*/
static int
getPerformanceData(UpdateQueryP query, HCOUNTER c, PDH_FMT_COUNTERVALUE* value, DWORD format) {
clock_t now = clock();
uint64_t now = GetTickCount64();

/*
* Need to limit how often we update the query
Expand Down