When I use the squareline to create UI ,which contains two screens and in which animation created by the image, both screen can switch to another one by button, I found memory leak by every switching to another screen

What do you want to achieve?

memory usage should not be increased when switching the screen every time

What have you tried so far?

if there are no animations on the screen ,then no memory leak (mem uasage not increase) even though i switch the screen to each, i cant find the reason of the menory leak,do i need to free the image obj manually? by the way, i use freeRTOS memory management, i am not sure whether it will accur the same problem on lvgl mem management

Screenshot or video


  • SquareLine Studio version:
  • Operating system:
  • Target hardware:

Please attache a very simple example project to reproduce the issue.

Hi,My simple example is as the picture shows

when I try to switch the screen by the button ,the mem size usage is as the picture shows,the animation is created by squareline with a pic,

however, when I continue to switch the screen many times , it seems that the usage of the mem becomes bigger and bigger ,which must lead to the mem problem finallly.
begin usage:23% final usage 30%.

In the meantime, i have try the mem menagement of freeRTOS ,it also has the problem like that, my question is :do I need to free the animation obj with the API manually ?how i can avoid this problem.TKS

Please attach the project itself to try it out on our end too. If you don’t want to share it publicly you can send it to forum@squareline.io too.

hi, i have sent the email with the attached file to you ,tks

Thank you.

I could reproduce the issue and found the problem too.

This is in code:

void ui_event_Screen1(lv_event_t * e)
    lv_event_code_t event_code = lv_event_get_code(e);
    lv_obj_t * target = lv_event_get_target(e);
    if(event_code == LV_EVENT_SCREEN_LOADED) {
        PLAY_MUSIC_Animation(ui_Screen1_Image1, 0);

It means the animation is created every time the screen is loaded. In SLS we should have on “starter” object or so where the user can start all the one-time init things (e.g. animations) but we don’t have this yet. :frowning:

As workaround we usually create a splash screen and in the splash screen’s SCREEN_LOADED event start the animations and immediately switch to the real first screen.

Tkanks for your following about this problem, i also try to use the GC function like “lv_anim_del()” to clear the mem before load the another new screen ,it really works just on the condition that there are no other animation on the other screen ,but it’s not so good.All in all, i hope the object of container or titleview widget can be used in the next version of SLS, then it will be easy to build the Sliding main menu of UI,which i think it’s a commonly usage for the GUI proj’

In v1.2 we will add the chart but after that we will work on the tabview.

Hi Jack,
can you show code for print memory usage.