I have a function periodically executed every 2 seconds, and after it runs about 4 hours, ''Out of memory, can’t allocate a new buffer (increase your LV_MEM_SIZE/heap size)" asserted in lv_mem.c @line 584. I have set LV_MEM_SIZE (36U *1024U), I think it is big enough for a screen with 256 * 64 of monocolour. And code is like this:
static char ucItem_Val[64] ={ 0};
static char *pChar = &ucItem_Val[0];
void Lcd_menu_disp(struct stlcd_menu_page_info *pmenu)
{
if(lv_scr_act() != main_page.lv_main_scr)
lv_scr_load(main_page.lv_main_scr);
MenuItem_S (*pTempMenuItem)[] = pmenu->pMenuItem;
MenuItem_S *pItem = (MenuItem_S *)(*pTempMenuItem);
pItem = pItem + pmenu->ucFirstItemIdx;
int i = 0;
while(i < MAX_ITEM_PER_PAGE)
{
memset(ucItem_Val, 0, 64);
lv_label_set_text(main_page.lv_label_item[i], “”);
lv_obj_clean_style_list(main_page.lv_label_item[i], LV_LABEL_PART_MAIN);
pChar = &ucItem_Val[0];
if(NULL != pItem->Item)
{
strcat(ucItem_Val, pItem->Item);
pChar += strlen(pItem->Item);
}
if(NULL != pItem->pValue)
{
memcpy(pChar, pItem->pValue->Value, PARAM_VAL_LEN);
}
else
{
}
if(i < pmenu->ucItemCount)
{
lv_label_set_text(main_page.lv_label_item[i], ucItem_Val);
if((i + pmenu->ucFirstItemIdx) == pmenu->ucMenuItemIdx)
{
static lv_style_t style;
lv_style_set_bg_color(&style, LV_STATE_DEFAULT, LV_COLOR_BLACK);
lv_style_set_bg_opa(&style, LV_STATE_DEFAULT, LV_OPA_COVER);
lv_style_set_text_color(&style, LV_STATE_DEFAULT, LV_COLOR_WHITE);
lv_obj_add_style(main_page.lv_label_item[i], LV_LABEL_PART_MAIN, &style);
}
}
i++;
pItem++;
}
}
main_page.lv_label_item[] are created at initializing time for once. I can’t find out which part caused the memory leakage. Need Help!
Thank you very much!