~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/win32utils.py

  • Committer: John Arbash Meinel
  • Date: 2009-02-18 03:28:11 UTC
  • mto: This revision was merged to the branch mainline in revision 4013.
  • Revision ID: john@arbash-meinel.com-20090218032811-cbuu15u5xobpltv9
Fix some small bugs, and prefer the ctypes form.

Show diffs side-by-side

added added

removed removed

Lines of Context:
100
100
def debug_memory_win32api(message='', short=True):
101
101
    """Use trace.note() to dump the running memory info."""
102
102
    from bzrlib import trace
103
 
    if has_win32api:
104
 
        import win32process
105
 
        proc = win32process.GetCurrentProcess()
106
 
        info = win32process.GetProcessMemoryInfo(proc)
107
 
    elif has_ctypes:
 
103
    if has_ctypes:
108
104
        class PROCESS_MEMORY_COUNTERS_EX(ctypes.Structure):
109
105
            """Used by GetProcessMemoryInfo"""
110
106
            _fields_ = [('cb', ctypes.c_ulong),
138
134
                'PeakPagefileUsage': mem_struct.PeakPagefileUsage,
139
135
                'PrivateUsage': mem_struct.PrivateUsage,
140
136
               }
 
137
    elif has_win32api:
 
138
        import win32process
 
139
        # win32process does not return PrivateUsage, because it doesn't use
 
140
        # PROCESS_MEMORY_COUNTERS_EX (it uses the one without _EX).
 
141
        proc = win32process.GetCurrentProcess()
 
142
        info = win32process.GetProcessMemoryInfo(proc)
141
143
    else:
142
144
        trace.note('Cannot debug memory on win32 without ctypes'
143
145
                   ' or win32process')
146
148
    trace.note('PeakWorking       %8d kB', info['PeakWorkingSetSize'] / 1024)
147
149
    if short:
148
150
        return
149
 
    # PagefileUsage et al seem to always be identical....
150
151
    trace.note('PagefileUsage     %8d kB', info.get('PagefileUsage', 0) / 1024)
151
152
    trace.note('PeakPagefileUsage %8d kB', info.get('PeakPagefileUsage', 0) / 1024)
152
 
    trace.note('PrivateUsage      %8d kB', info.get('PeakPagefileUsage', 0) / 1024)
 
153
    trace.note('PrivateUsage      %8d kB', info.get('PrivateUsage', 0) / 1024)
153
154
    trace.note('PageFaultCount    %8d', info.get('PageFaultCount', 0))
154
155
 
155
156