Coder Social home page Coder Social logo

Memory issue about openfontrender HOT 5 OPEN

copantok avatar copantok commented on June 12, 2024
Memory issue

from openfontrender.

Comments (5)

llapp0612 avatar llapp0612 commented on June 12, 2024 1

Can confirm memory leaks with loadFont() in a loop till system crashing an reseting.

Update

Checked library and my code, found out, that the library haven't memory leak. A memory leak appear with following code

`function1(){
loadFont();
...
function2();
...
unloadFont();
}

function2(){
loadfont();
drawFont();
unloadFont();
}`

Correct will be:

Example 1

`function1(){
loadFont();
drawFont();
unloadFont();
...
function2();
}

function2(){
loadfont();
drawFont();
unloadFont();
}`

Example 2

`function1(){
...
function2();
...
}

function2(){
loadfont();
drawFont();
unloadFont();
}`

from openfontrender.

llapp0612 avatar llapp0612 commented on June 12, 2024 1

Here is my Git

What microcontroller is used? Is the development environment Arduino?
First, have coded with a Arduino board, later switched to ESP32 Dev Board and changed a bit code for ESP32.

Are the fonts to be loaded the same? Are they different?
If you look into my code, you will see there is no different.

Are the fonts loaded from SD?
No. Not tested from SD.

Is there one instance of OpenFontRender? More than one?
I use many Times loadFont() and after that unLoadFont(), but i never use loadFont() loadFont() and then unloadFont() unloadFont(), because, this is the reason for memory leak.

Where is function1 called from? setup or loop?
Yes, in loop

from openfontrender.

takkaO avatar takkaO commented on June 12, 2024

@copantok , @llapp0612

Where do you load fonts from?
Also, can you provide the smallest complete code that can reproduce the problem?

Thank you.

from openfontrender.

llapp0612 avatar llapp0612 commented on June 12, 2024

it have nothing to do with the font itself.

when you use doubles time loadFont() and use unloadFont(), you will get a memory leak. i had posted the smallest code.

this is incorrect:

void function1(){
loadFont();
<-- any code -->
function2();
<-- any code -->
unloadFont();
}

void function2(){
loadfont();
drawFont();
unloadFont();
}

in this example, load font will be load, then a call to function2 with loadFont again without unloadFont before. after second time loadFont comes unloadFont and a second time again. this is not working and will get a memory leak. after loadfont, you will need to unloadFont again, after that u can call the LoadFont again.

from openfontrender.

takkaO avatar takkaO commented on June 12, 2024

@llapp0612

Please tell me a complete sketch (code) that can be executed by copy-paste to accurately verify the issue.
I have some overall picture with your minimal code, but I do not understand some of the details.

  • What microcontroller is used?
  • Is the development environment Arduino?
  • Are the fonts to be loaded the same? Are they different?
  • Are the fonts loaded from SD?
  • Is there one instance of OpenFontRender? More than one?
  • Where is function1 called from? setup or loop?

Thank you.

from openfontrender.

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.