Skip to content

Commit 4719682

Browse files
jbrockmendelclaude
andcommitted
BENCH: fix Windows peak working-set query (ctypes handle typing)
GetProcessMemoryInfo returned falsy because the process pseudo-handle was passed as a default c_int; declare HANDLE/BOOL arg/return types so peak_rss_mb is populated on Windows. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
1 parent cbe2198 commit 4719682

1 file changed

Lines changed: 11 additions & 4 deletions

File tree

scripts/bench_read_csv_parallel.py

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -139,12 +139,19 @@ class _PMC(ctypes.Structure):
139139
("PeakPagefileUsage", ctypes.c_size_t),
140140
]
141141

142+
get_proc = ctypes.windll.kernel32.GetCurrentProcess
143+
get_proc.restype = wintypes.HANDLE
144+
get_info = ctypes.windll.psapi.GetProcessMemoryInfo
145+
get_info.argtypes = [
146+
wintypes.HANDLE,
147+
ctypes.POINTER(_PMC),
148+
wintypes.DWORD,
149+
]
150+
get_info.restype = wintypes.BOOL
151+
142152
counters = _PMC()
143153
counters.cb = ctypes.sizeof(_PMC)
144-
handle = ctypes.windll.kernel32.GetCurrentProcess()
145-
if ctypes.windll.psapi.GetProcessMemoryInfo(
146-
handle, ctypes.byref(counters), counters.cb
147-
):
154+
if get_info(get_proc(), ctypes.byref(counters), counters.cb):
148155
return counters.PeakWorkingSetSize / 1024 / 1024
149156
return None
150157
try:

0 commit comments

Comments
 (0)