wonho-maker / Adafruit_SH1106

Adafruit graphic library for SH1106 dirver lcds.
Other
162 stars 93 forks source link

High dynamic memory usage by SH1106 library #11

Open Jonoox opened 5 years ago

Jonoox commented 5 years ago

Hi, your lib in my program takes 1000 bytes more of dynamic memory than SSD1306 library.

Your library SH1106: The global variable use 1.577 byte (77%) of dynamic memory, leaving 471 byte free for local variables. The max is 2.048 byte. Low memory available, stability problems may occur.

SSD1306: The global variable use 563 byte (27%) of dynamic memory, leaving 1485 byte free for local variables.

That's because of you not using PROGMEM anywhere in library.

muhit313 commented 3 years ago

I also notice that the library is not using PROGMEM anywhere. It uses huge dynamic memory (70% to 77%). Which is not good. So I think it should be modified.

muhit313 commented 3 years ago

@wonho-maker can you try to solve this issue? Its an major issue for me.

choudharyanil244 commented 2 years ago

I have solve this issue of huge dynamic memory

theintel commented 1 year ago

I have solve this issue of huge dynamic memory

Does your forked library resolve the issue?

Andy2No commented 1 year ago

@theintel You might want to also look at the Adafruit_SH110x library. I compiled one of the examples for an Arduino Uno, which uses nearly 60% of the available code space, while only using 29% of the dynamic memory:

"Sketch uses 18770 bytes (58%) of program storage space. Maximum is 32256 bytes. Global variables use 614 bytes (29%) of dynamic memory, leaving 1434 bytes for local variables. Maximum is 2048 bytes."

However, it might make more sense to use an Atmega 2560, or an Atmega 1284P, for the extra memory, for use with a graphical display.

theintel commented 1 year ago

@Andy2No Thanks for that suggestion. It is the neatest solution.

choudharyanil244 commented 1 year ago

I have solve this issue of huge dynamic memory

Does your forked library resolve the issue?

Yes

https://github.com/choudharyanil244/Adafruit_SH1106/commit/e51c33eab98f102e420b59a0e043e1986b249ad8

theintel commented 1 year ago

@choudharyanil244 Thanks a lot. I'll give it a go.

choudharyanil244 commented 1 year ago

@choudharyanil244 Thanks a lot. I'll give it a go.

Sure try it out and let me know the results.

theintel commented 1 year ago

@choudharyanil244 I tried it out. I wanted to check the real-time dynamic memory usage using freeMemory() following this tutorial

I included Serial.println(freeMemory()) in different parts of the sketch and this was your library's result:
Screenshot_20230221-045217

And this was the actual library's: Screenshot_20230221-044957

Sorry for dragging this old thread. I don’t exactly know if this represents optimization performance of the library. So someone's expertise would be helpful.