Rev 4013: Fix some small bugs, and prefer the ctypes form. in http://bzr.arbash-meinel.com/branches/bzr/1.12/win32_mem
John Arbash Meinel
john at arbash-meinel.com
Wed Feb 18 03:28:29 GMT 2009
At http://bzr.arbash-meinel.com/branches/bzr/1.12/win32_mem
------------------------------------------------------------
revno: 4013
revision-id: john at arbash-meinel.com-20090218032811-cbuu15u5xobpltv9
parent: john at arbash-meinel.com-20090218030943-j3dhzwnijugzim61
committer: John Arbash Meinel <john at arbash-meinel.com>
branch nick: win32_mem
timestamp: Tue 2009-02-17 21:28:11 -0600
message:
Fix some small bugs, and prefer the ctypes form.
-------------- next part --------------
=== modified file 'bzrlib/win32utils.py'
--- a/bzrlib/win32utils.py 2009-02-18 03:09:43 +0000
+++ b/bzrlib/win32utils.py 2009-02-18 03:28:11 +0000
@@ -100,11 +100,7 @@
def debug_memory_win32api(message='', short=True):
"""Use trace.note() to dump the running memory info."""
from bzrlib import trace
- if has_win32api:
- import win32process
- proc = win32process.GetCurrentProcess()
- info = win32process.GetProcessMemoryInfo(proc)
- elif has_ctypes:
+ if has_ctypes:
class PROCESS_MEMORY_COUNTERS_EX(ctypes.Structure):
"""Used by GetProcessMemoryInfo"""
_fields_ = [('cb', ctypes.c_ulong),
@@ -138,6 +134,12 @@
'PeakPagefileUsage': mem_struct.PeakPagefileUsage,
'PrivateUsage': mem_struct.PrivateUsage,
}
+ elif has_win32api:
+ import win32process
+ # win32process does not return PrivateUsage, because it doesn't use
+ # PROCESS_MEMORY_COUNTERS_EX (it uses the one without _EX).
+ proc = win32process.GetCurrentProcess()
+ info = win32process.GetProcessMemoryInfo(proc)
else:
trace.note('Cannot debug memory on win32 without ctypes'
' or win32process')
@@ -146,10 +148,9 @@
trace.note('PeakWorking %8d kB', info['PeakWorkingSetSize'] / 1024)
if short:
return
- # PagefileUsage et al seem to always be identical....
trace.note('PagefileUsage %8d kB', info.get('PagefileUsage', 0) / 1024)
trace.note('PeakPagefileUsage %8d kB', info.get('PeakPagefileUsage', 0) / 1024)
- trace.note('PrivateUsage %8d kB', info.get('PeakPagefileUsage', 0) / 1024)
+ trace.note('PrivateUsage %8d kB', info.get('PrivateUsage', 0) / 1024)
trace.note('PageFaultCount %8d', info.get('PageFaultCount', 0))
More information about the bazaar-commits
mailing list