Skip to content

Memory not be fully freed when lv_scr_load_anim() time of animation is 0 #4212

@SendToSouthEast

Description

@SendToSouthEast

LVGL Version: tag 8.3.6 (my esp-idf version cannot compile tag 8.3.7)
Platform: ESP32

Description:

It is very strange that when I use lv_scr_load_anim(scr, LV_SCR_LOAD_ANIM_FADE_ON, 400, 0, true); to load the screen with a time of animation of 0, the memory can be correctly loaded and freed. However, when I use lv_scr_load_anim(dictScene,LV_SCR_LOAD_ANIM_NONE,0,0,true); the memory cannot be completely freed, which leads to a crash after repeatedly loading the interface multiple times. Through mem monitor, I found that the memory is not completely freed. When I use lv_scr_load_anim(dictScene,LV_SCR_LOAD_ANIM_NONE,10,0,true);, the memory can be correctly released.
For example, when a screen is opened, it may use 7.1K of memory, but when another screen is opened and then returned to the original screen, the memory usage may increase to 8.3K.

Here is my test code.

lv_obj_t* scr;
lv_obj_t* scr1;

void win_test1(void)
 {
     scr = lv_obj_create(NULL);
     lv_obj_set_size(scr, LV_HOR_RES, LV_VER_RES);
     static lv_style_t style;
     lv_style_reset(&style);
     lv_style_init(&style);
     lv_style_set_bg_color(&style, lv_palette_main(LV_PALETTE_RED));
     lv_style_set_text_color(&style, lv_color_white());
     lv_obj_add_style(scr, &style,NULL);

     lv_obj_t* label = lv_label_create(scr);
     lv_obj_set_style_text_color(label, lv_color_hex(0x990000), LV_PART_MAIN | LV_STATE_DEFAULT);
    

     lv_label_set_text(label, "This is a test 1");

     lv_scr_load_anim(scr, LV_SCR_LOAD_ANIM_FADE_ON, 400, 0, true);
     printf("win test 1 is created ");
 }

 void win_test2(void)
 {
     scr1 = lv_obj_create(NULL);
     lv_obj_set_size(scr1, LV_HOR_RES, LV_VER_RES);
     static lv_style_t style;
     lv_style_reset(&style);
     lv_style_init(&style);
     lv_style_set_bg_color(&style, lv_palette_main(LV_PALETTE_BLUE));
     lv_style_set_text_color(&style, lv_color_white());
     
     lv_obj_add_style(scr1, &style,NULL);

     lv_obj_t* label = lv_label_create(scr1);
     lv_obj_set_style_text_color(label, lv_color_hex(0x990000), LV_PART_MAIN | LV_STATE_DEFAULT);

     lv_label_set_text(label, "This is a test 2");
     
     lv_scr_load_anim(scr1, LV_SCR_LOAD_ANIM_FADE_ON, 0, 0,true);
     printf("win test 2 is created ");
 }
while (1)
    {
        vTaskDelay(pdMS_TO_TICKS(10));
        keyCheakTask();
        lv_task_handler();

        static uint16_t i;
        if (++i > 100) {
            i = 0;
            static bool flag;
            if (flag)
            {
                flag = false;
                win_test2();
            }
            else
            {
                flag = true;
                win_test1();
            }
            
      	}

    }

Another issue that is not related to the above test code is that I was not familiar with the usage of screens earlier, so I manually created a interface using Scene = lv_obj_create(lv_scr_act()); and created interface widgets with Scene as the parent object. When I call lv_del_obj(Scene) to log out of this interface, the memory cannot be completely released. It can only release 30% to 70% of the memory. I want to know if this is because I did not use the function correctly or for other reasons. However, the symptoms of this issue appear very similar to the previously mentioned issue.

Thank you for your response!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions