From 73cd8c241cb57a1f858b5f2f31e737ab339b8301 Mon Sep 17 00:00:00 2001 From: Kevin O'Connor Date: Wed, 16 Sep 2020 21:42:24 -0400 Subject: [PATCH] klippy: Call gc.collect() on a "restart" request Explicitly run the python garbage collector on a restart. This cleans up memory from the previous session. Signed-off-by: Kevin O'Connor --- klippy/klippy.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/klippy/klippy.py b/klippy/klippy.py index 187b45e5..03095d06 100644 --- a/klippy/klippy.py +++ b/klippy/klippy.py @@ -1,10 +1,10 @@ #!/usr/bin/env python2 # Main code for host side printer firmware # -# Copyright (C) 2016-2018 Kevin O'Connor +# Copyright (C) 2016-2020 Kevin O'Connor # # This file may be distributed under the terms of the GNU GPLv3 license. -import sys, os, optparse, logging, time, threading, collections, importlib +import sys, os, gc, optparse, logging, time, threading, collections, importlib import util, reactor, queuelogger, msgproto, homing import gcode, configfile, pins, mcu, toolhead, webhooks @@ -312,6 +312,7 @@ def main(): if bglogger is not None: bglogger.clear_rollover_info() bglogger.set_rollover_info('versions', versions) + gc.collect() main_reactor = reactor.Reactor() printer = Printer(main_reactor, bglogger, start_args) res = printer.run() @@ -319,6 +320,7 @@ def main(): break time.sleep(1.) main_reactor.finalize() + main_reactor = printer = None logging.info("Restarting printer") start_args['start_reason'] = res