Garbage collection added

This commit is contained in:
2026-04-17 22:19:48 +02:00
parent 9a25805522
commit 7be9b59093

View File

@@ -1128,6 +1128,7 @@ def main():
ota.mark_ok() ota.mark_ok()
except: except:
pass pass
gc.collect()
last_heartbeat = utime.ticks_ms() last_heartbeat = utime.ticks_ms()
@@ -1136,6 +1137,7 @@ def main():
now = utime.ticks_ms() now = utime.ticks_ms()
check_wifi() check_wifi()
gc.collect()
if not check_mqtt(): if not check_mqtt():
utime.sleep_ms(1000) utime.sleep_ms(1000)
@@ -1145,6 +1147,7 @@ def main():
service_discovery() service_discovery()
arduino_recv() arduino_recv()
_flush_backlight_state() _flush_backlight_state()
gc.collect()
# Periodic re-home # Periodic re-home
for i in range(num_gauges): for i in range(num_gauges):
@@ -1157,6 +1160,8 @@ def main():
info(f"Heartbeat: {gauge_targets}") info(f"Heartbeat: {gauge_targets}")
publish_state(client_ref) publish_state(client_ref)
last_heartbeat = now last_heartbeat = now
gc.collect()
info(f"Heap free: {gc.mem_free()} bytes")
utime.sleep_ms(10) utime.sleep_ms(10)
@@ -1164,6 +1169,7 @@ def main():
import sys import sys
sys.print_exception(e) sys.print_exception(e)
log_err(f"Main loop error: {e} — continuing") log_err(f"Main loop error: {e} — continuing")
gc.collect()
utime.sleep_ms(100) utime.sleep_ms(100)