def memoryUsed(self): try: global osPrcs if self.isMSW: if osPrcs is None: import win32process as osPrcs return osPrcs.GetProcessMemoryInfo(osPrcs.GetCurrentProcess())['WorkingSetSize'] / 1024 elif sys.platform == "sunos5": # ru_maxrss is broken on sparc if osPrcs is None: import resource as osPrcs return int(subprocess.getoutput("ps -p {0} -o rss".format(os.getpid())).rpartition('\n')[2]) else: # unix or linux where ru_maxrss works import resource as osPrcs return osPrcs.getrusage(osPrcs.RUSAGE_SELF).ru_maxrss # in KB except Exception: pass return 0