Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

memory allocation failed #2

Open
simonchen007 opened this issue May 18, 2020 · 15 comments
Open

memory allocation failed #2

simonchen007 opened this issue May 18, 2020 · 15 comments

Comments

@simonchen007
Copy link
Contributor

hello,

I'm using esp32 + lvgl + lv_lib_lodepng,
but when I use a png more 20K , it would shows "memory allocation failed", where can I change for making the memory allocation bigger ?

@embeddedt
Copy link
Member

You probably have to increase LV_MEM_SIZE (or the size of whatever heap you use).

@simonchen007
Copy link
Contributor Author

I change it as (64U * 1024U),still the same. however, I change it as 128U * 1024U , I would goes to compile error.

@kisvegabor
Copy link
Member

lodepng uses normal malloc. So you are simply out of heap on ESP.

@simonchen007
Copy link
Contributor Author

so, are you meaning the problem is because the esp32 having not enough money ?
I tested over 50 times last night, if the PNG is over 5kb, I would get this error.
however, if I use the normal way(make the png as c-array first), and do not use lodepng, 100kb png file is also works.

@kisvegabor
Copy link
Member

so, are you meaning the problem is because the esp32 having not enough money ?

I don't know how much money ESP has but it might be out of memory. 🙂 :

The resolution of the PNG matters. During decoding the PNG image a hor. res x ver.res. x color size array is allocated into RAM. E.g. for 200 px x 200 px x 2 bytes = ~80kB

@simonchen007
Copy link
Contributor Author

esp32 having 320K memory.
And I read the code of lodepng, "memory allocation failed" is because case 83 . if esp32 out of memory, I would not send any error, it would just go reboot.

@kisvegabor
Copy link
Member

What is the resolution of the image?

@simonchen007
Copy link
Contributor Author

320*480

@kisvegabor
Copy link
Member

kisvegabor commented May 19, 2020

It means the decompressed image is 3202402 = 300kB. If it uses 32-bit color format internally (I'm not sure now) than its 600 kB. Anyway, 320kB is not enough in either case.

@simonchen007
Copy link
Contributor Author

but why if I use the normal way(make the png as c-array first), and do not use lodepng, even 100kb png file is works ?

@embeddedt
Copy link
Member

The PNG doesn't need to be decoded into RAM first with that method. It can be drawn directly from flash to the display.

@rambo-panda
Copy link

I also encountered the problem under lvgl 8.3. But I found two ways to solve it

  1. #LV_MEM_CUSTOM 1 use the malloc and free realloc
  2. convert to *.bin file

waiting for the real solution 😄

@kisvegabor
Copy link
Member

You can increase LV_MEM_SIZE to add more memory for LVGL.

@rambo-panda
Copy link

rambo-panda commented Feb 17, 2023 via email

@rambo-panda
Copy link

@kisvegabor

apologize to you. it's my mistake.

I just committed git and found that the changelog had a change that I had debugged.
It affected the lvgl allocation

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants