fix(meshchat, health_monitor): add garbage collection calls to cleanup resources during context teardown and health checks

This commit is contained in:
Ivan
2026-05-09 01:03:59 -05:00
parent 9f04aef66a
commit b84ade45f8
2 changed files with 4 additions and 0 deletions
+2
View File
@@ -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,
@@ -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):