Lvgl v9 memory usage

Hello.
I migrated a project from version 8.3 to version 9 and noticed strange behavior when working with memory. In v8:

#define LV_MEM_SIZE (55 * 1024U)          /*[bytes]*/

After upgrading to v9, with the same disign I received messages:

[D] lv_log_cb:84   [7708]:LVGL:[2] [Warn]	(316.094, +316094)	 lv_draw_buf_create: No memory: 200x100, cf: 16, stride: 800, 80000Byte,  lv_draw_buf.c:186
[D] lv_log_cb:84   [7708]:LVGL:[2] [Warn]	(316.094, +0)	 lv_draw_layer_alloc_buf: Allocating layer buffer failed. Try later lv_draw.c:376

I tried increasing LV_MEM_SIZE and at a size of 140 * 1024 everything worked. The increase is more than 2 times and this is a lot for an embedded system.
I monitor memory usage and call a function:

void mem_report(void){
    lv_mem_monitor_t mon;

    lv_mem_monitor(&mon);
    DEBUG("Total: %d free: %d max: %d used: %d%%",mon.total_size,mon.free_size,mon.max_used,mon.used_pct);
}

Maximum usage I’ve seen:

[D] mem_report:312  [7671]:Total: 141316 free: 134584 max: 72583 used: 5%

Maximum usage - 72583. But with LV_MEM_SIZE = 100 * 1024 I got “No memory” message.

Why is this happening? How to determine exactly how much memory is needed? Is there any way to reduce memory consumption?

2 Likes