From 0bb7f92c093bee1eee8936e8e1f4633e79b64fb1 Mon Sep 17 00:00:00 2001 From: cobolbaby Date: Fri, 10 Apr 2020 16:28:01 +0800 Subject: [PATCH 1/2] fix: process_resident_memory_bytes detected is incorrect in Win7 32bit Ref: https://github.com/prometheus/client_golang/issues/728 Signed-off-by: Cobolbaby --- prometheus/process_collector_windows.go | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/prometheus/process_collector_windows.go b/prometheus/process_collector_windows.go index e0b935d1f..15e687367 100644 --- a/prometheus/process_collector_windows.go +++ b/prometheus/process_collector_windows.go @@ -36,15 +36,15 @@ type processMemoryCounters struct { // https://docs.microsoft.com/en-us/windows/desktop/api/psapi/ns-psapi-_process_memory_counters_ex _ uint32 PageFaultCount uint32 - PeakWorkingSetSize uint64 - WorkingSetSize uint64 - QuotaPeakPagedPoolUsage uint64 - QuotaPagedPoolUsage uint64 - QuotaPeakNonPagedPoolUsage uint64 - QuotaNonPagedPoolUsage uint64 - PagefileUsage uint64 - PeakPagefileUsage uint64 - PrivateUsage uint64 + PeakWorkingSetSize uint + WorkingSetSize uint + QuotaPeakPagedPoolUsage uint + QuotaPagedPoolUsage uint + QuotaPeakNonPagedPoolUsage uint + QuotaNonPagedPoolUsage uint + PagefileUsage uint + PeakPagefileUsage uint + PrivateUsage uint } func getProcessMemoryInfo(handle windows.Handle) (processMemoryCounters, error) { From c6babafd276e1385135ae3b8644d07b908d7fbd3 Mon Sep 17 00:00:00 2001 From: cobolbaby Date: Mon, 13 Apr 2020 10:43:29 +0800 Subject: [PATCH 2/2] feat: Change processMemoryCounters struct uint declaration to uintptr Signed-off-by: cobolbaby --- prometheus/process_collector_windows.go | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/prometheus/process_collector_windows.go b/prometheus/process_collector_windows.go index 15e687367..f973398df 100644 --- a/prometheus/process_collector_windows.go +++ b/prometheus/process_collector_windows.go @@ -33,18 +33,22 @@ var ( ) type processMemoryCounters struct { - // https://docs.microsoft.com/en-us/windows/desktop/api/psapi/ns-psapi-_process_memory_counters_ex + // System interface description + // https://docs.microsoft.com/en-us/windows/desktop/api/psapi/ns-psapi-process_memory_counters_ex + + // Refer to the Golang internal implementation + // https://golang.org/src/internal/syscall/windows/psapi_windows.go _ uint32 PageFaultCount uint32 - PeakWorkingSetSize uint - WorkingSetSize uint - QuotaPeakPagedPoolUsage uint - QuotaPagedPoolUsage uint - QuotaPeakNonPagedPoolUsage uint - QuotaNonPagedPoolUsage uint - PagefileUsage uint - PeakPagefileUsage uint - PrivateUsage uint + PeakWorkingSetSize uintptr + WorkingSetSize uintptr + QuotaPeakPagedPoolUsage uintptr + QuotaPagedPoolUsage uintptr + QuotaPeakNonPagedPoolUsage uintptr + QuotaNonPagedPoolUsage uintptr + PagefileUsage uintptr + PeakPagefileUsage uintptr + PrivateUsage uintptr } func getProcessMemoryInfo(handle windows.Handle) (processMemoryCounters, error) {