mirror of
https://github.com/MarekZegare4/MeshCore-Solo.git
synced 2026-07-26 23:08:11 +00:00
perf(ui): shrink message-history rings to free heap
QuickMsgScreen held the on-device scrollback in two RAM rings, each slot a full MSG_TEXT_BUF: CH_HIST_MAX=96 + DM_HIST_MAX=64 made the screen object ~31 KB on the heap (allocated at boot, never freed). On the Wio variant (MAX_CONTACTS=350, OFFLINE_QUEUE_SIZE=256) that left only ~3 KB free heap, so allocations in the input/menu path failed and entering Diagnostics hung the device. Halve the rings to CH_HIST_MAX=48 / DM_HIST_MAX=32, recovering ~14 KB of free heap (measured 3->17 KB). History is RAM-only (lost on reboot anyway); the cost is shorter on-device scrollback. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -45,11 +45,12 @@ class QuickMsgScreen : public UIScreen {
|
||||
FullscreenMsgView _fs;
|
||||
int _unread_at_entry; // _ch_unread value when entering CHANNEL_HIST
|
||||
int _viewing_max_seen; // highest _hist_sel reached in current session
|
||||
// Shared ring for all channels combined. Sized to comfortably exceed
|
||||
// typical inter-visit accumulation; addChannelMsg() decrements the
|
||||
// Shared ring for all channels combined. addChannelMsg() decrements the
|
||||
// matching _ch_unread when an entry is evicted so the badge can't claim
|
||||
// unread messages that no longer exist in the ring.
|
||||
static const int CH_HIST_MAX = 96;
|
||||
// unread messages that no longer exist in the ring. Each slot carries a full
|
||||
// MSG_TEXT_BUF, so this ring dominates the screen's RAM footprint — kept
|
||||
// modest to leave heap headroom (see DM_HIST_MAX).
|
||||
static const int CH_HIST_MAX = 48;
|
||||
|
||||
// KEYBOARD
|
||||
KeyboardWidget* _kb;
|
||||
@@ -126,7 +127,8 @@ class QuickMsgScreen : public UIScreen {
|
||||
uint8_t attempt; // last attempt number sent (outgoing); next resend = attempt+1
|
||||
uint8_t resends_left; // remaining auto-resends before the marker shows ✗
|
||||
};
|
||||
static const int DM_HIST_MAX = 64;
|
||||
// Each slot carries a full MSG_TEXT_BUF; kept modest to bound heap use.
|
||||
static const int DM_HIST_MAX = 32;
|
||||
DmHistEntry _dm_hist[DM_HIST_MAX];
|
||||
int _dm_hist_head, _dm_hist_count;
|
||||
int _dm_hist_sel, _dm_hist_scroll;
|
||||
|
||||
Reference in New Issue
Block a user