Packet statistics retain per-node heap allocations after node eviction
Los mantenedores suelen responder en 1 día
Evaluación
- Dificultad
- 4/5
- Tiempo estimado
- 3-5 días
- Aptitud para principiantes
- 45/100
- Tipo de issue
- Error
- Claridad
- Bien especificado
- Estado de actividad
- Tranquilo
- Stack tecnológico
- cpp
- Área
- embedded-iot
Línea de trabajo
Read source/graphics/TFT/TFTView_320x240.cpp, especially updateStatistics(), purgeNode(), and packetReceived(); first trace how statistics entries relate to node eviction and packet updates. The report proposes a bounded reusable container and removal of evicted-node statistics. Done means statistics stay within MAX_NUM_NODES_VIEW, reuse storage after eviction, and the LoRa and NoLoRa MUI variants build successfully.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
Describe the bug
TFTView_320x240::updateStatistics() keeps one statistics entry per packet sender in a function-static std::list. Every previously unseen sender creates a small allocation, and the list is only cleared by the manual statistics-reset path (p.from == 0). It is not pruned when purgeNode() evicts a UI node at MAX_NUM_NODES_VIEW.
On ESP32-S3 targets with PSRAM, these small list-node allocations remain in internal heap. With a large or MQTT-fed node database near the 250-node view limit, sender churn therefore causes internal heap to decline slowly even though the visible node set is bounded and PSRAM remains stable. The existing // TODO: stop if memory limit is reached marks the missing bound.
packetReceived() also calls updateStatistics(p) for every packet, independently of whether the statistics panel is visible.
There is a second bookkeeping problem in the same function: the rendering loop uses for (auto it2 : stats), so assignments such as it2.row = row modify a copy and are not retained.
Relevant code on current master (44b86e1):
updateStatistics()and its static listpurgeNode()- Unconditional statistics update from
packetReceived()
To Reproduce
- Build an ESP32-S3 MUI target and monitor internal free heap, minimum free heap, largest internal block, and PSRAM.
- Synchronize a large node database and receive packets from many distinct senders. MQTT traffic makes this easy to reproduce.
- Keep the UI at or near
MAX_NUM_NODES_VIEW, so old UI nodes are purged while new senders arrive. - Run for several hours and compare internal heap against sender/node churn.
In one five-hour run with 305 one-minute samples:
- Internal free heap changed from 80,356 to 73,724 bytes (
-6,632bytes). - PSRAM free remained approximately 1.58 MB and stable.
- There were 89 node-add events at the 250-node cap, involving 75 distinct newly observed senders/nodes.
- No panic, watchdog reset, reboot, or allocation failure occurred.
- The largest internal free block remained stable at 8,180 bytes.
This retained memory is still reachable through the static container, so an ordinary leak detector may not classify it as a leak.
Expected behavior
Packet statistics should be bounded to the UI node capacity and should be removed when the corresponding UI node is evicted. After the container's initial capacity is allocated, observing another sender should reuse existing storage rather than create another small internal-heap allocation.
Suggested repair
I tested the following bounded design locally:
- Move the statistics container from function-static storage to a
TFTView_320x240member. - Replace
std::list<Stats>with a reusablestd::vector<PacketStats>. - Reserve
MAX_NUM_NODES_VIEWonce on PSRAM-capable ESP32-S3 targets. - Enforce
MAX_NUM_NODES_VIEWas a hard fallback bound even if node/statistics lifetimes become temporarily inconsistent. - Add
purgeNodeStatistics(nodeNum)and call it frompurgeNode()whenever a node is evicted. - Erase entries without shrinking vector capacity, allowing later senders to reuse the allocation.
- Sort and render entries in place, or otherwise remove/fix the copy-based row bookkeeping in
for (auto it2 : stats). - Optionally avoid rewriting LVGL table cells when their displayed values have not changed.
This repair changes only statistics bookkeeping. It does not discard mesh packets or messages and does not alter the radio TX/RX queues.
The local implementation builds successfully for both LoRa and NoLoRa MUI variants. In early validation with more than 160 restored statistics entries, vector capacity stayed fixed at 250 and internal heap was approximately 9 KB higher than the previous build at comparable uptime. Longer-duration validation is still useful, so this report focuses on the deterministic unbounded retention and the bounded-container repair rather than claiming that every heap trend is eliminated.
Screenshots / Photos
Not applicable; the problem is visible in heap diagnostics rather than in the rendered UI.
Device (please complete the following information):
- Type: Custom Waveshare T147 ESP32-S3 MUI target with 8 MB PSRAM
- Exact version: Meshtastic 2.8.0 local build; Device UI master
44b86e1 - Firmware download source: Local PlatformIO build
- Other attached hardware: None required
Additional logs
The measurements above were captured once per minute. Node identifiers and message content were intentionally omitted; neither is needed to reproduce the allocation pattern.
- Lenguaje dominante
- C
- Estrellas
- 499
- Forks
- 125
- Merge medio
- 1 d 5 h
- PR fusionados (30 d)
- 38
Preparar el entorno
Inicia el contenedor de desarrollo del proyecto en tu navegador, con tu propia cuenta de GitHub.
- Sin Dockerfile ni archivo de Docker Compose
- Sin plantilla de pull request
- Sin guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de meshtastic/device-ui
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 65/100
meshtastic/device-ui#283 · 2 comentarios ·
Los mantenedores suelen responder en 1 día
-
[2.7.26] T-Deck MUI: device reboots when opening a direct message from the Nodes screen (any node)Abierto
Dificultad 4/5 3-5 días Aptitud para principiantes 48/100
meshtastic/device-ui#498 · 1 comentario ·
Los mantenedores suelen responder en 1 día
-
Dependency DashboardPosiblemente ocupada @mverch67 la tomó hace 13 días. Abierto
meshtastic/device-ui#473 · 2 asignados ·
Los mantenedores suelen responder en 1 día
-
Show the connect QR code on MUIAbierto
Dificultad 3/5 1-2 días Aptitud para principiantes 55/100
meshtastic/device-ui#457 ·
Los mantenedores suelen responder en 1 día
-
[Bug]: Meshtastic UI shows wrong region and modem preset on screen after settiong is updatedAbiertobug
Dificultad 3/5 1-2 días Aptitud para principiantes 45/100
meshtastic/device-ui#503 · 2 comentarios ·
Los mantenedores suelen responder en 1 día
Todos los issues de meshtastic/device-ui
Issues similares
-
area/docdb kind/failing-test priority/medium status/awaiting-triage
Dificultad 2/5 1-3 horas Aptitud para principiantes 82/100
yugabyte/yugabyte-db#39462 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 70/100
libreswan/libreswan#3185 · 1 comentario ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 75/100
Los mantenedores suelen responder en 3 días
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 70/100
-
[SDL3pp] update to 0.12.0Abiertocategory:port-update
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
Los mantenedores suelen responder en 2 días