Hi @kisvegabor , @embeddedt
I have a problem with memory when using lv_freetype.
Maybe there’s something that have not been freed.
Could you help me check it.
Description
I am using freetype library + lv_freetype to display ttf font.
I just init font and then destroy it right now to check allocated memory by using lv_mem_monitor.
I use lv_task to call this step (init, destroy font, check mem) each 1s.
Each time, the value of free_size is decreased some kilo-bytes.
After a period of time, free_size ~ 0,
Finally, in lv_ft_font_init_nocache(), face_info = lv_mem_alloc(…) is failed.
What LVGL version are you using?
Lvgl Ver 7.4.0
lv_freetype release/v7
expect
Init font and then destroy, memory size must be back to previous value.
For ex:
free_size = 100
init font => free_size = 90
destroy font => free_size = 100
Code to reproduce
lv_freetype.h
#define LV_USE_FT_CACHE_MANAGER 0
lv_freetype.c
static bool lv_ft_font_init_nocache(lv_ft_info_t * info)
{
...
//FT_Error error = FT_New_Face(library, info->name, 0, &face);
FT_Error error = FT_New_Memory_Face(library, ttfData, 21684, 0, &face);
}
My app
static lv_mem_monitor_t mon1;
static void test_memory(lv_task_t * task)
{
/* init freetype library */
lv_freetype_init(64, 1, 0);
/*Create a font*/
info_1.name = "font";
info_1.weight = 30;
info_1.style = FT_FONT_STYLE_NORMAL;
lv_ft_font_init(&info_1);
/*Destroy a font*/
lv_ft_font_destroy(info_1.font);
/*Check memory (mon1.free_size) */
lv_mem_monitor(&mon1);
}
void lv_task_internal_init(void)
{
lv_task_t * task = NULL;
task = lv_task_create(test_memory, 1000, LV_TASK_PRIO_MID, NULL);
}