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>
This commit is contained in:
parent
7d83aed410
commit
73cd8c241c
|
@ -1,10 +1,10 @@
|
||||||
#!/usr/bin/env python2
|
#!/usr/bin/env python2
|
||||||
# Main code for host side printer firmware
|
# 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.
|
# 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 util, reactor, queuelogger, msgproto, homing
|
||||||
import gcode, configfile, pins, mcu, toolhead, webhooks
|
import gcode, configfile, pins, mcu, toolhead, webhooks
|
||||||
|
|
||||||
|
@ -312,6 +312,7 @@ def main():
|
||||||
if bglogger is not None:
|
if bglogger is not None:
|
||||||
bglogger.clear_rollover_info()
|
bglogger.clear_rollover_info()
|
||||||
bglogger.set_rollover_info('versions', versions)
|
bglogger.set_rollover_info('versions', versions)
|
||||||
|
gc.collect()
|
||||||
main_reactor = reactor.Reactor()
|
main_reactor = reactor.Reactor()
|
||||||
printer = Printer(main_reactor, bglogger, start_args)
|
printer = Printer(main_reactor, bglogger, start_args)
|
||||||
res = printer.run()
|
res = printer.run()
|
||||||
|
@ -319,6 +320,7 @@ def main():
|
||||||
break
|
break
|
||||||
time.sleep(1.)
|
time.sleep(1.)
|
||||||
main_reactor.finalize()
|
main_reactor.finalize()
|
||||||
|
main_reactor = printer = None
|
||||||
logging.info("Restarting printer")
|
logging.info("Restarting printer")
|
||||||
start_args['start_reason'] = res
|
start_args['start_reason'] = res
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue