def getOwnProcessMemoryUsage():
    'Memory usage of own process in bytes.'
    if isWin32Windows():
        import ctypes.wintypes

        class PROCESS_MEMORY_COUNTERS_EX(ctypes.Structure):
            _fields_ = [('cb', ctypes.wintypes.DWORD), ('PageFaultCount', ctypes.wintypes.DWORD), ('PeakWorkingSetSize', ctypes.c_size_t), ('WorkingSetSize', ctypes.c_size_t), ('QuotaPeakPagedPoolUsage', ctypes.c_size_t), ('QuotaPagedPoolUsage', ctypes.c_size_t), ('QuotaPeakNonPagedPoolUsage', ctypes.c_size_t), ('QuotaNonPagedPoolUsage', ctypes.c_size_t), ('PagefileUsage', ctypes.c_size_t), ('PeakPagefileUsage', ctypes.c_size_t), ('PrivateUsage', ctypes.c_size_t)]
        GetProcessMemoryInfo = ctypes.windll.psapi.GetProcessMemoryInfo
        GetProcessMemoryInfo.argtypes = [ctypes.wintypes.HANDLE, ctypes.POINTER(PROCESS_MEMORY_COUNTERS_EX), ctypes.wintypes.DWORD]
        GetProcessMemoryInfo.restype = ctypes.wintypes.BOOL
        counters = PROCESS_MEMORY_COUNTERS_EX()
        rv = GetProcessMemoryInfo(ctypes.windll.kernel32.GetCurrentProcess(), ctypes.byref(counters), ctypes.sizeof(counters))
        if (not rv):
            raise ctypes.WinError()
        return counters.PrivateUsage
    else:
        import resource
        if isMacOS():
            factor = 1
        else:
            factor = 1024
        return (resource.getrusage(resource.RUSAGE_SELF).ru_maxrss * factor)
Memory usage of own process in bytes.
def getOwnProcessMemoryUsage():
    
    if isWin32Windows():
        import ctypes.wintypes

        class PROCESS_MEMORY_COUNTERS_EX(ctypes.Structure):
            _fields_ = [('cb', ctypes.wintypes.DWORD), ('PageFaultCount', ctypes.wintypes.DWORD), ('PeakWorkingSetSize', ctypes.c_size_t), ('WorkingSetSize', ctypes.c_size_t), ('QuotaPeakPagedPoolUsage', ctypes.c_size_t), ('QuotaPagedPoolUsage', ctypes.c_size_t), ('QuotaPeakNonPagedPoolUsage', ctypes.c_size_t), ('QuotaNonPagedPoolUsage', ctypes.c_size_t), ('PagefileUsage', ctypes.c_size_t), ('PeakPagefileUsage', ctypes.c_size_t), ('PrivateUsage', ctypes.c_size_t)]
        GetProcessMemoryInfo = ctypes.windll.psapi.GetProcessMemoryInfo
        GetProcessMemoryInfo.argtypes = [ctypes.wintypes.HANDLE, ctypes.POINTER(PROCESS_MEMORY_COUNTERS_EX), ctypes.wintypes.DWORD]
        GetProcessMemoryInfo.restype = ctypes.wintypes.BOOL
        counters = PROCESS_MEMORY_COUNTERS_EX()
        rv = GetProcessMemoryInfo(ctypes.windll.kernel32.GetCurrentProcess(), ctypes.byref(counters), ctypes.sizeof(counters))
        if (not rv):
            raise ctypes.WinError()
        return counters.PrivateUsage
    else:
        import resource
        if isMacOS():
            factor = 1
        else:
            factor = 1024
        return (resource.getrusage(resource.RUSAGE_SELF).ru_maxrss * factor)