aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKevin O'Connor <kevin@koconnor.net>2020-09-16 21:42:24 -0400
committerKevin O'Connor <kevin@koconnor.net>2020-09-16 23:53:45 -0400
commit73cd8c241cb57a1f858b5f2f31e737ab339b8301 (patch)
treee9428ea61d8c2c60a5b600ccc6eddc4e747c33f5
parent7d83aed410711bce66038bd50b3aa36254c2ea8c (diff)
downloadkutter-73cd8c241cb57a1f858b5f2f31e737ab339b8301.tar.gz
kutter-73cd8c241cb57a1f858b5f2f31e737ab339b8301.tar.xz
kutter-73cd8c241cb57a1f858b5f2f31e737ab339b8301.zip
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 <kevin@koconnor.net>
-rw-r--r--klippy/klippy.py6
1 files 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 <kevin@koconnor.net>
+# Copyright (C) 2016-2020 Kevin O'Connor <kevin@koconnor.net>
#
# 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