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 evalTest(code, N): from System import GC startMem = GC.GetTotalMemory(True) startTime = clock() evalLoop(code, N) endTime = clock() if is_mono: gc.collect() else: gc.collect(2) endMem = GC.GetTotalMemory(True) return max(endMem - startMem, 0)
def __form_closed_fired(self, sender, args): ''' This method is called just after this form closes. ''' # deregister listers; prevents infinite loop! self.__scraper.start_scrape_listeners.remove(self.__start_scrape) self.__scraper.cancel_listeners.remove(self.close_threadsafe) # in some cases, we should interpret the closing of this form as # a request by the user to cancel the entire scrape operation... if self.__cancel_on_close: self.__scraper.cancel() # clean up and disposal self.__current_book = None self.__current_page = 0 self.__pbox_panel.Dispose(True) del self.__pbox_panel GC.Collect()
def get_memory(): for _ in range(4): GC.Collect() GC.WaitForPendingFinalizers() return GC.GetTotalMemory(True) / 1e6
def gcwait(): GC.Collect() GC.WaitForPendingFinalizers()
def onClick(sender, args): GC.Collect()