EtherCard icon indicating copy to clipboard operation
EtherCard copied to clipboard

Reduce the memory used by the library making printIp method optional.

Open mrv96 opened this issue 5 years ago • 3 comments

Hi, in file webutil.cpp there is method printIp. Also if it is not used, the dynamic memory for Serial library call is used. Due to the frequent memory capacity problem on Arduino, is there a way to exclude it from the library if not used in order to reduce the dynamic memory used? I think that this issue is present only in this file and in this method. Thank you very much.

mrv96 avatar Jan 13 '19 17:01 mrv96

Hi,

I am not entirely clear what you are asking.

The Arduino linker is very good at only including code that you call from your Arduino sketch. So if you don't call printIp, then it shouldn't pull in the Serial code - and reduce the Programme Memory and RAM used.

Does that help?

nick.

njh avatar Jan 13 '19 18:01 njh

withserial withoutserial

Me too believed in Arduino linker efficiency, but as you can see in the screenshots, if i comment Serial code the total amount of dynamic memory reduces. I can guarantee that i don't use printIp method in my code.

mrv96 avatar Jan 13 '19 20:01 mrv96

Hm! That is really annoying. I wonder what is going on. It must have something to do with Serial being a global variable.

ArduinoJson uses a printTo() method that allows you to write to anything that is a subclass of Print.

I guess that would be a way of removing the reference to Serial - but it would break lots of people's code.

njh avatar Jan 14 '19 09:01 njh