I have some memory problem when handing image. we display different images on same page/screen by call lv_img_set_src(lv_obj_t * img, const void * src_img), the memory increases when src_img is not same as the previous image, but doesn’t increase when src_img is same as the previous image. It seems that there’s image caching for image variable. Could you explain why the memory is still not released after calling function lv_obj_del? How to reduce/release the memory? It impacts my platform performance. This memory increase is not expected.
Below is the code. The function display_signal(SignalStrengthId_t sigStrId) is triggered several times. I find memory increases when the function display_signal is triggered at the first time, and memory also increases when the input parameter is not same, but doesn’t increase when input parameter is same as the previous.
static lv_obj_t *sgImgScr3 = NULL;
void clear_img_screen3(void)
{
if (NULL != sgImgScr3) {
lv_obj_del(sgImgScr3);
sgImgScr3 = NULL;
}
}
void draw_connect_lost()
{
if (NULL == sgImgScr3) {
sgImgScr3 = lv_img_create(sgPage, NULL);
}
lv_img_set_src(sgImgScr3, &connectLostIdx16);
lv_obj_set_pos(sgImgScr3, 50, 50);
}
void draw_wireless_signal(SignalStrengthId_t sigStrId)
{
// determine image src
lv_img_dsc_t *wSigImgSrc = NULL;
switch (sigStrId) {
case STRENGTH_WEAKEST:
wSigImgSrc = (lv_img_dsc_t *)&picWSignal1;
break;
case STRENGTH_POOL:
wSigImgSrc = (lv_img_dsc_t *)&picWSignal2;
break;
case STRENGTH_NORMAL:
wSigImgSrc = (lv_img_dsc_t *)&picSignal3;
break;
default:
wSigImgSrc = (lv_img_dsc_t *)&picWSignal1;
break;
}
// display the image
if (NULL == sgImgScr3) {
sgImgScr3 = lv_img_create(sgPage, NULL);
}
lv_img_set_src(sgImgScr3, wSigImgSrc);
lv_obj_set_pos(sgImgScr3, 138, 63);
}
void display_signal(SignalStrengthId_t sigStrId)
{
// clear the screen
clear_img_screen3();
// draw wireless signal image
if (sigStrId == NO_SINGAL)
{
draw_connect_lost();
}
else {
draw_wireless_signal(sigStrId);
}
}