def __exit__(self, type, value, traceback): "Quit the app and perform garbage collection" if self._app is not None: self._app.Quit() self._app = None GC.Collect() GC.WaitForPendingFinalizers() GC.Collect() GC.WaitForPendingFinalizers()
def tearDown(self): import clr from System import GC for i in range(3): GC.Collect() GC.WaitForPendingFinalizers() if os.path.isfile(self.filename): os.unlink(self.filename)
def gcwait(): """ Attempt to force a garbage collection, and wait for pending finalizers. If you think you need to call this function, you're probably wrong. """ for _ in range(4): _mapper.DemandCleanup() GC.Collect() GC.WaitForPendingFinalizers()
def get_memory(): for _ in range(4): GC.Collect() GC.WaitForPendingFinalizers() return GC.GetTotalMemory(True) / 1e6
def gcwait(): GC.Collect() GC.WaitForPendingFinalizers()