How to resolve Out of memory issue


Hi All,
how to resolve Out of memory (0x00000000) error.
i am getting below error when i run my code

Warn: Couldn’t allocate memory |(lv_mem.c #199 lv_mem_alloc())
Error: lv_obj_create |(lv_obj.c #309 lv_obj_create())
Error: Out of memory (0x00000000) |(lv_debug.c #127 lv_debug_log_error())
How to increase memory?

What MCU/Processor/Board and compiler are you using?


What LVGL version are you using?


What do you want to achieve?

how to resolve out of memory issue.

What have you tried so far?

Code to reproduce

Add a code snippet which can run in the simulator. It should contain only the relevant code that compiles without errors when separated from your main code base.

The code block(s) should be formatted like:

/*You code here*/

Screenshot and/or video

If possible, add screenshots and/or videos about the current state.

This error can mean one of two things:

  • You’re creating too many objects and there isn’t enough heap space to fit them (rare if your heap size is reasonable).
  • You have a memory leak in your code (very common).

The most common memory leak I know of in v7 & v8 is reinitializing styles with lv_style_init instead of lv_style_reset.

yes i am creating more objects. is there any solution for this?

It depends on your heap size and exactly what you are making; it’s difficult for me to provide a generic solution that works in all cases.

One tip that may help is to delete objects when they aren’t visible on the screen, but again, the effectiveness of this depends on your specific application, and you would have to think about how to architect the UI logic to work with this approach.