Lv_demo_widgets memory frag

every time i click “Dark” switch to change color, the memory frag becomes larger

memory used become lager too

Might it be that styles or something are initialized again? I had a problem similar with my own project though and the cause was that i initialized my styles every time i called a function, and you should only do it once i think

Are you using LVGL’s memory manager (LV_MEM_CUSTOM == 0) or your own?

yes,LV_MEM_CUSTOM == 0,you can try the lv_demo_widgets and see the memory changes

every time i change the ''Dark" switch ,memory used ang frag become larger.

I can’t reproduce this on the PC simulator after rapidly switching back and forth at least a hundred times. The memory log is below and it doesn’t look like there is a leak:

used:  32392 ( 13 %), frag:   1 %, biggest free: 228336
used:  32512 ( 13 %), frag:   1 %, biggest free: 228336
used:  32536 ( 13 %), frag:   1 %, biggest free: 228336
used:  32648 ( 13 %), frag:   1 %, biggest free: 227880
used:  32664 ( 13 %), frag:   2 %, biggest free: 226752
used:  32640 ( 13 %), frag:   2 %, biggest free: 226976
used:  32512 ( 13 %), frag:   1 %, biggest free: 228336
used:  32520 ( 13 %), frag:   2 %, biggest free: 227208
used:  32624 ( 13 %), frag:   1 %, biggest free: 228336
used:  32512 ( 13 %), frag:   1 %, biggest free: 228336

Are you using the latest version of LVGL?