diff --git a/meshchatx/meshchat.py b/meshchatx/meshchat.py index 1367e5f..5a5ceac 100644 --- a/meshchatx/meshchat.py +++ b/meshchatx/meshchat.py @@ -850,6 +850,7 @@ class ReticulumMeshChat: if identity_hash in self.contexts: del self.contexts[identity_hash] self.current_context = None + gc.collect() def _teardown_all_contexts_for_reload(self): # Stop per-identity long-running services before tearing down contexts. @@ -879,6 +880,7 @@ class ReticulumMeshChat: self.contexts.clear() self.current_context = None self.running = False + gc.collect() async def _send_rns_reload_status( self, diff --git a/meshchatx/src/backend/recovery/health_monitor.py b/meshchatx/src/backend/recovery/health_monitor.py index 5a63100..93d2ca1 100644 --- a/meshchatx/src/backend/recovery/health_monitor.py +++ b/meshchatx/src/backend/recovery/health_monitor.py @@ -12,6 +12,7 @@ from in-memory deques kept by PersistentLogHandler and psutil. import asyncio import collections +import gc import json import logging import threading @@ -59,6 +60,7 @@ class HealthMonitor: self._check() except Exception as exc: _log.debug("HealthMonitor check error: %s", exc) + gc.collect() await asyncio.sleep(self.CHECK_INTERVAL) def _check(self):