~ubuntu-branches/ubuntu/quantal/enigmail/quantal-security

« back to all changes in this revision

Viewing changes to mozilla/build/win32/procmem.py

  • Committer: Package Import Robot
  • Author(s): Chris Coulson
  • Date: 2013-09-13 16:02:15 UTC
  • mfrom: (0.12.16)
  • Revision ID: package-import@ubuntu.com-20130913160215-u3g8nmwa0pdwagwc
Tags: 2:1.5.2-0ubuntu0.12.10.1
* New upstream release v1.5.2 for Thunderbird 24

* Build enigmail using a stripped down Thunderbird 17 build system, as it's
  now quite difficult to build the way we were doing previously, with the
  latest Firefox build system
* Add debian/patches/no_libxpcom.patch - Don't link against libxpcom, as it
  doesn't exist anymore (but exists in the build system)
* Add debian/patches/use_sdk.patch - Use the SDK version of xpt.py and
  friends
* Drop debian/patches/ipc-pipe_rename.diff (not needed anymore)
* Drop debian/patches/makefile_depth.diff (not needed anymore)

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# This Source Code Form is subject to the terms of the Mozilla Public
 
2
# License, v. 2.0. If a copy of the MPL was not distributed with this
 
3
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
4
 
 
5
import os, sys, ctypes, ctypes.wintypes
 
6
 
 
7
class VM_COUNTERS(ctypes.Structure):
 
8
    _fields_ = [("PeakVirtualSize", ctypes.wintypes.ULONG),
 
9
                ("VirtualSize", ctypes.wintypes.ULONG),
 
10
                ("PageFaultCount", ctypes.wintypes.ULONG),
 
11
                ("PeakWorkingSetSize", ctypes.wintypes.ULONG),
 
12
                ("WorkingSetSize", ctypes.wintypes.ULONG),
 
13
                ("QuotaPeakPagedPoolUsage", ctypes.wintypes.ULONG),
 
14
                ("QuotaPagedPoolUsage", ctypes.wintypes.ULONG),
 
15
                ("QuotaPeakNonPagedPoolUsage", ctypes.wintypes.ULONG),
 
16
                ("QuotaNonPagedPoolUsage", ctypes.wintypes.ULONG),
 
17
                ("PagefileUsage", ctypes.wintypes.ULONG),
 
18
                ("PeakPagefileUsage", ctypes.wintypes.ULONG)
 
19
                ]
 
20
 
 
21
def get_vmsize(handle):
 
22
    """
 
23
    Return (peak_virtual_size, virtual_size) for the process |handle|.
 
24
    """
 
25
    ProcessVmCounters = 3
 
26
    vmc = VM_COUNTERS()
 
27
    if ctypes.windll.ntdll.NtQueryInformationProcess(int(handle),
 
28
                                                     ProcessVmCounters,
 
29
                                                     ctypes.byref(vmc),
 
30
                                                     ctypes.sizeof(vmc),
 
31
                                                     None) == 0:
 
32
       return (vmc.PeakVirtualSize, vmc.VirtualSize)
 
33
 
 
34
    return (-1, -1)
 
35
 
 
36
if __name__ == '__main__':
 
37
    PROCESS_QUERY_INFORMATION = 0x0400
 
38
    for pid in sys.argv[1:]:
 
39
        handle = ctypes.windll.kernel32.OpenProcess(PROCESS_QUERY_INFORMATION,
 
40
                                                    0, # no inherit
 
41
                                                    int(pid))
 
42
        if handle:
 
43
            print "Process %s:" % pid
 
44
            vsize, peak_vsize = get_vmsize(handle)
 
45
            print "peak vsize: %d" % peak_vsize
 
46
            ctypes.windll.kernel32.CloseHandle(handle)
 
47
        else:
 
48
            print "Couldn't open process %s" % pid