Compare commits

...
1 Commits
Author SHA1 Message Date
alfrix 8af5c0b2d4 Trace memory 2023-03-24 08:12:19 -06:00
3 changed files with 25 additions and 0 deletions

No files matched your search

+2
View File
@@ -357,6 +357,8 @@ class JobStatusPanel(ScreenPanel):
if self.flow_timeout is None:
self.flow_timeout = GLib.timeout_add_seconds(2, self.update_flow)
self._screen.base_panel_show_all()
logging.debug("Job_status panel")
self._screen.memory_trace()
def deactivate(self):
if self.flow_timeout is not None:
+2
View File
@@ -82,6 +82,7 @@ class PrintPanel(ScreenPanel):
if self.cur_directory != "gcodes":
self.change_dir(None, "gcodes")
self._refresh_files()
logging.debug("Print panel")
def add_directory(self, directory, show=True):
parent_dir = os.path.dirname(directory)
@@ -414,6 +415,7 @@ class PrintPanel(ScreenPanel):
def _refresh_files(self, widget=None):
self._files.refresh_files()
self._screen.memory_trace()
def show_rename(self, widget, fullpath):
self.source = fullpath
+21
View File
@@ -10,6 +10,7 @@ import traceback # noqa
import locale
import sys
import gi
import tracemalloc
gi.require_version("Gtk", "3.0")
from gi.repository import Gtk, Gdk, GLib, Pango
@@ -90,8 +91,11 @@ class KlipperScreen(Gtk.Window):
reinit_count = 0
max_retries = 4
initialized = False
initial_snapshot = None
switch_count = 0
def __init__(self, args, version):
tracemalloc.start()
try:
super().__init__(title="KlipperScreen")
except Exception as e:
@@ -216,6 +220,23 @@ class KlipperScreen(Gtk.Window):
self.files = KlippyFiles(self)
self._ws.initial_connect()
def memory_trace(self):
snapshot = tracemalloc.take_snapshot()
snapshot = snapshot.filter_traces((
tracemalloc.Filter(False, "<frozen importlib._bootstrap_external>"),
tracemalloc.Filter(False, "<unknown>"),
tracemalloc.Filter(False, tracemalloc.__file__),
))
if self.initial_snapshot is None:
self.initial_snapshot = snapshot
logging.debug("[ Initial memory snapshot ]")
else:
self.switch_count += 1
logging.debug("[ Top 10 memory diffs (Shown: %d times)]", self.switch_count)
top_stats = snapshot.compare_to(self.initial_snapshot, 'lineno')
for stat in top_stats[:10]:
logging.debug(stat)
def ws_subscribe(self):
requested_updates = {
"objects": {