Heap usage for static objects

Hello! I am making a GUI in a barebones C enviroment and am using LVGL to make the GUI. Our RAM size is fairly limited with a maximum alllocation of 14336 bytes being possible for the heap. We ideally only want to use static objects, to prevent having to manually manage memory and more importantly, prevent fragmentation.
Now we have reached a point where our heap is full though and I have been doing some researching to find out what is taking up a lot of space.
I´ve decided to analyze a single view in our GUI which looks as following:

It consists of: (Header and footer not included)

  • 1 body object
  • 3 line objects
  • 11 label objects
  • 3 styles for the fonts

For each of these objects, I’ve checked how much RAM was being allocated by setting a breakpoint in line 125 of lv_mem.c. This is in the lv_mem_alloc(size_t size) function. I simply noted the passed size for all objects and their respective calls in setup.
For example, we made a horizontal line as following:

//Create the lower horizontal line
STATIC lv_point_t lineHor2Points[] = {{0, 178}, {200, 178}};
GUIView_statisticsLineHor2 = lv_line_create(GUIView_statistics1BodyBox);
lv_line_set_points(GUIView_statisticsLineHor2, lineHor2Points, 2); lv_obj_add_style(GUIView_statisticsLineHor2, &style_lineStats, 0);

This lead to 72 bytes being allocated. The sum of all these objects is 1474 bytes. However when I check this heap size change with this setting in lv_conf.h

#define LV_USE_MEM_MONITOR      1

I see a difference of 2.3kB (simply commented out all the setup for the above shown screen). Now this 900 bytes difference is pretty significant in our case and we’d really like to know where this memory is going. What am I not seeing which is causing this difference? What is taking up more heap space other than the static objects I declared for this above view?

A secondary question, are there any things we should look out for with limited heap space in mind? Any optimizations which are obvious and can give us some quick space? Or any practices we should avoid when trying to limit heap usage?

Thanks in advance!

What MCU/Processor/Board and compiler are you using?

Renesas R7FA2L1AB with a ILI9341 display
Using the GCC toolchain

What LVGL version are you using?


What do you want to achieve?

I want to know what is taking up the full 2.3kB of heap usage I see when we add the view described above. I’ve found 1474 to be alloced for static objects but the rest is mystery to me.

Additionally, I would like to know what some good practices are when considering limited heap space.

What have you tried so far?

I’ve tried using the MEM_TRACE capabilities within LVGL, but seeing as our only option of logging is to print to console over UART, this did not give me a great overview of dynamic memory usage.

Code to reproduce