use of new() and delete() (std::string, std::unique_ptr, apps loading in InfiniTime)
LittleFS
NimBLE
LVGL support custom memory manager, so I simply edited the configuration to point the alloc/free functions to FreeRTOS memory manager.
For other parts of the code that use malloc(), delete(), new(), free(), I defined custom implementations of malloc(), free(), realloc() so that they'll be linked in the code in place of the ones from stdlib. This ensures that the heap from stdlib is not used anymore.
In the end, here's a rough overview of the memory allocation:
I used this branch for multiple days and the minimum memory available in the FreeRTOS heap was around 6KB. Which means that we still have ~6KB of RAM available for static allocation (we'll need a bit of this for the new HR implementation) or for dynamic allocation (for new apps, fonts,...).
This PR unifies the 3 memory heaps used in InfiniTime (stdlib, LVGL and FreeRTOS) into a single memory space managed by FreeRTOS.
The goals are
According to the memory analysis I've previously done, dynamic memory allocations (which consume heap memory) are done in multiple parts of the code:
new()
anddelete()
(std::string, std::unique_ptr, apps loading in InfiniTime)LVGL support custom memory manager, so I simply edited the configuration to point the alloc/free functions to FreeRTOS memory manager. For other parts of the code that use malloc(), delete(), new(), free(), I defined custom implementations of
malloc()
,free()
,realloc()
so that they'll be linked in the code in place of the ones from stdlib. This ensures that the heap from stdlib is not used anymore.In the end, here's a rough overview of the memory allocation:
This leaves 784B unallocated at build time.
I used this branch for multiple days and the minimum memory available in the FreeRTOS heap was around 6KB. Which means that we still have ~6KB of RAM available for static allocation (we'll need a bit of this for the new HR implementation) or for dynamic allocation (for new apps, fonts,...).