Coder Social home page Coder Social logo

free memory about lv_lib_png HOT 6 CLOSED

lvgl avatar lvgl commented on May 28, 2024
free memory

from lv_lib_png.

Comments (6)

kisvegabor avatar kisvegabor commented on May 28, 2024

Isn't it resolve to free here?

from lv_lib_png.

glory-man avatar glory-man commented on May 28, 2024

Isn't it resolve to free here?

lodepng.c uses lodepng_malloc() and lodepng_realloc() to allocate memory, which could be implemented independed from lodepng (especially if LODEPNG_COMPILE_ALLOCATORS not defined). And users which use this lib with RTOS can use OS allocators. You can also use lv_mem_ allocators, which can use heap/memory independend from system malloc(). And this is strange if lodepng use lv_mem_alloc() to allocate memory, but lv_png use system free() to free it. Potential memory leakage. It will be better to use lodepng_free() instead of free().

from lv_lib_png.

glory-man avatar glory-man commented on May 28, 2024

This problem may occur even if I will use latest branch of lvgl with lv_png as extra lib. For example, if I define in my project LODEPNG_NO_COMPILE_ALLOCATORS-macro and will create my own independent allocators (lodepng_malloc(), lodepng_realloc(), lodepng_free()) that won't use lv_mem_alloc()/realloc() but will use some memory region. In this case lodepng will use my allocators to allocate memory for png_data and dsc->img_data, but in lv_png this memory will not be freed because it uses lv_mem_free(), which has no information about where the memory was allocated. I think in this case also will be better to use lodepng_free() instead of lv_mem_free() (I mean lvgl-branch).

from lv_lib_png.

kisvegabor avatar kisvegabor commented on May 28, 2024

Got it.

Although, this lib is not required for v8 and v7 is already EOL, I'd be be happy to merge a PR if you send one.

from lv_lib_png.

glory-man avatar glory-man commented on May 28, 2024

I didn't test this changes - but it should work:
#29 - PR for release/v7 branch
#30 - PR for master branch

from lv_lib_png.

kisvegabor avatar kisvegabor commented on May 28, 2024

Both are merged, thanks!

from lv_lib_png.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.