diff --git a/examples/simple_secure_chat_ui/main.cpp b/examples/simple_secure_chat_ui/main.cpp index b4d2f7d9e..9343764e3 100644 --- a/examples/simple_secure_chat_ui/main.cpp +++ b/examples/simple_secure_chat_ui/main.cpp @@ -1152,6 +1152,9 @@ void initializeMesh() { msgstore_load_public(); uiManager->endPublicHistoryLoad(); + Serial.printf("[ui] free heap: %u B free PSRAM: %u B\n", + esp_get_free_heap_size(), esp_get_free_internal_heap_size()); + Serial.println("[mesh] Sending self-advert..."); the_mesh.sendSelfAdvert(1200); Serial.println("[mesh] Advert queued (1200ms delay)"); diff --git a/examples/simple_secure_chat_ui/uiManager.cpp b/examples/simple_secure_chat_ui/uiManager.cpp index 20d4225f3..ae801b0e4 100644 --- a/examples/simple_secure_chat_ui/uiManager.cpp +++ b/examples/simple_secure_chat_ui/uiManager.cpp @@ -272,6 +272,7 @@ void UIManager::addPrivateChatBubble(const char *time_str, const char *msg, bool LV_FLEX_ALIGN_START, LV_FLEX_ALIGN_START ); + if (!row) { Serial.println("[ui] OOM: addPrivateChatBubble row alloc failed"); return; } // 2. Bubble column: message text + timestamp below lv_obj_t* aligner = LvObj(row) diff --git a/lib/lvgl/lv_conf.h b/lib/lvgl/lv_conf.h index 40af9b9f5..b5e9f82ac 100644 --- a/lib/lvgl/lv_conf.h +++ b/lib/lvgl/lv_conf.h @@ -46,7 +46,10 @@ *=========================*/ /*1: use custom malloc/free, 0: use the built-in `lv_mem_alloc()` and `lv_mem_free()`*/ -#define LV_MEM_CUSTOM 0 +/* ESP32-S3 has 8 MB OPI PSRAM. Switching to LV_MEM_CUSTOM=1 lets LVGL use the + system heap (which includes PSRAM on this board) instead of a fixed 48 KB + static pool. This prevents OOM crashes when loading many chat bubbles. */ +#define LV_MEM_CUSTOM 1 #if LV_MEM_CUSTOM == 0 /*Size of the memory available for `lv_mem_alloc()` in bytes (>= 2kB)*/ #define LV_MEM_SIZE (48U * 1024U) /*[bytes]*/