Skip to content

Commit

Permalink
[test\find_memleak.py] Use WinDLL instead of oledll/windll
Browse files Browse the repository at this point in the history
Partially fix enthought#735
  • Loading branch information
moi15moi committed Jan 12, 2025
1 parent 41a71b5 commit cbd9fbf
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions comtypes/test/find_memleak.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,14 @@ def dump(self):
for n, _ in self._fields_[2:]:
print(n, getattr(self, n) / 1e6)

_psapi = WinDLL("psapi")

_GetProcessMemoryInfo = _psapi.GetProcessMemoryInfo
_GetProcessMemoryInfo.argtypes = [HANDLE, POINTER(PROCESS_MEMORY_COUNTERS), DWORD]
_GetProcessMemoryInfo.restype = BOOL

try:
windll.psapi.GetProcessMemoryInfo.argtypes = (
_GetProcessMemoryInfo.argtypes = (
HANDLE,
POINTER(PROCESS_MEMORY_COUNTERS),
DWORD,
Expand All @@ -43,7 +48,7 @@ def find_memleak(func, loops=None):
def wss():
# Return the working set size (memory used by process)
pmi = PROCESS_MEMORY_COUNTERS()
if not windll.psapi.GetProcessMemoryInfo(-1, byref(pmi), sizeof(pmi)):
if not _GetProcessMemoryInfo(-1, byref(pmi), sizeof(pmi)):
raise WinError()
return pmi.WorkingSetSize

Expand Down

0 comments on commit cbd9fbf

Please sign in to comment.