LVGL Memory usage

Looking for inputs.
I am working on a project in platformIO with lvgl that has screens (menu options). Began with an ESP32 8 meg and ran into the issue of crashes (everything froze requiring a reboot) .
Swapped over to a 16meg and things are better.
Memory settings are:
in the ini:
board_upload.flash_size = 16MB
board_upload.maximum_size = 16777216
board_build.partitions = default_16MB.csv
My main.ccp specs out:
#define DRAW_BUF_SIZE (TFT_HOR_RES * TFT_VER_RES / 20 * (LV_COLOR_DEPTH / 8))
static lv_color_t buf[ TFT_HOR_RES * TFT_VER_RES / 10 ];
uint32_t draw_buf[DRAW_BUF_SIZE / 4];


in my lv_conf.h there is

#define LV_COLOR_DEPTH 16
#define LV_DRAW_LAYER_SIMPLE_BUF_SIZE (24 * 1024)

why is the monitor showing 24/25 kb??

Hi @kbrussow

I didn’t do the math on how much you expect it to take, but did you also take into account that each object also store their data (position, styles, etc…) ?

There are a plethora of questions that need to be answered to know what is causing your issue.

What kind of a display are you using? SPI, I8080, RGB or DSI?
What ESP32 are you using? The entire model number…
What is the resolution of the attached display?
What driver package are you using for the display?

It also appears that when you say that you switched to using a 16mb version that what you did was switch to a 16MB flash version and not a 16mb of RAM version. So your issue is more than likely not being caused by a “memory” problem but something else.

You may also want to read the documentation for using LVGL version 9 because you are using things for LVGL v8 that don’t work any more in v9.

thank you for the reply:
this is the 16Mb chip I am using
esp32-16
My display is a SPI 480x320 here are all the specs:


I am using TFT_espi to be my board interface to LVGL
in TFT_espi driver is

 #include <User_Setups/Setup21_ILI9488.h>           // Setup file for ESP32 and ILI9488 SPI bus TFT

the ST7796U did not work for me but using the ILI9488 did…
I know I am in over my head and asking newbie questions. I am a C# coder. Seems like a lot of platformIO and LVGL is hit and miss, find something that kinda works and move on.

I ran a diagnostic on my chip and the configuration and it showed

(30) boot: chip revision: v1.0
I (33) boot.esp32: SPI Speed      : 40MHz
I (37) boot.esp32: SPI Mode       : DIO
I (40) boot.esp32: SPI Flash Size : 16MB
I (44) boot: Enabling RNG early entropy source...
I (49) boot: Partition Table:
I (51) boot: ## Label            Usage          Type ST Offset   Length
I (57) boot:  0 nvs              WiFi data        01 02 00009000 00005000
I (64) boot:  1 otadata          OTA data         01 00 0000e000 00002000
I (70) boot:  2 app0             OTA app          00 10 00010000 00640000
I (77) boot:  3 app1             OTA app          00 11 00650000 00640000
I (83) boot:  4 spiffs           Unknown data     01 82 00c90000 00360000
I (90) boot:  5 coredump         Unknown data     01 03 00ff0000 00010000
I (97) boot: End of partition table
I (100) esp_image: segment 0: paddr=00010020 vaddr=3f400020 size=09ac0h ( 39616) map
I (121) esp_image: segment 1: paddr=00019ae8 vaddr=3ff80000 size=00020h (    32) load
I (121) esp_image: segment 2: paddr=00019b10 vaddr=3ffb0000 size=023bch (  9148) load
I (128) esp_image: segment 3: paddr=0001bed4 vaddr=40080000 size=04144h ( 16708) load
I (139) esp_image: segment 4: paddr=00020020 vaddr=400d0020 size=135f8h ( 79352) map
I (167) esp_image: segment 5: paddr=00033620 vaddr=40084144 size=08f34h ( 36660) load
I (188) boot: Loaded app from partition at offset 0x10000
I (188) boot: Disabling RNG early entropy source...
I (198) cpu_start: Multicore app
I (207) cpu_start: Pro cpu start user code
I (207) cpu_start: cpu freq: 160000000 Hz

Dont waste time and first learn how lvgl realy works. Primary if you dont set in conf custom memory management , then here is set fixed memory size for lvgl. From your 24kB and 43% your setup is around 56kB. 8M or 16M is irelevant…
Next chaos is

#define DRAW_BUF_SIZE (TFT_HOR_RES * TFT_VER_RES / 20 * (LV_COLOR_DEPTH / 8))
static lv_color_t buf[ TFT_HOR_RES * TFT_VER_RES / 10 ];
uint32_t draw_buf[DRAW_BUF_SIZE / 4];

so it looks like you do not have any additional PSRAM the ESP32 has a total of 520KB or RAM and of that there is about 320KB available for user use. If you are using WiFi or Bluetooth that number drops significantly.

I would need to see all of your code in order to tell you what needs to be done.

If you want to get an esp32 that will have more than ample resources to do whatever you want then look into getting an esp32-s3-devkit N16R8 or esp32-s3-devkit N32R8. This will have 8mb of ram VS the 320 you have available to you with the one you are using and it will either have 16mb of flash storage or 32mb of flash storage.

Thank you for your input, there is a load of things with LVGL to try to process and absorb. My hope here is to work with developers that are more knowledgeable than I to offer where I should be focusing my learning. Any advice you have is more than welcome.

Thank you for the input, I do have a N16R8 primed and ready to go… just need to make sure the pinouts are the same as my 16k board… Will keep you posted as I need to add in bluetooth and wifi and a light strip… My have to daisy chain out another esp23 to handle that portion. The deeper I dig, the darker the hole becomes. (said by most esp developers)