lasselukkari / aWOT

Arduino web server library.
MIT License
283 stars 41 forks source link

Sketch size too High? #120

Closed plckr closed 3 years ago

plckr commented 3 years ago

Hello,

I tried this library on a Arduino Mega, I used your Ethernet Example, and it increased 15% on my current sketch, is that normal? That's too much. Size before Library: 74% Size after Library; 89%

lasselukkari commented 3 years ago

When I compile the aWOT Ethernet example for Arduino Mega using the latest released version 3.3.1 I get this:

Sketch uses 22522 bytes (8%) of program storage space. Maximum is 253952 bytes.
Global variables use 2080 bytes (25%) of dynamic memory, leaving 6112 bytes for local variables. Maximum is 8192 bytes.

If I compile the WebServer example that comes with the Ethernet library I get:

Sketch uses 13360 bytes (5%) of program storage space. Maximum is 253952 bytes.
Global variables use 769 bytes (9%) of dynamic memory, leaving 7423 bytes for local variables. Maximum is 8192 bytes.

So that what is expected by including the library vs using the raw tcp server. The overhead is 9162 bytes of program storage space and 1311 bytes of dynamic memory. The latest version in the master branch that has not been yet released will save a few more bytes. When compiled with the latest master I get:

Sketch uses 22624 bytes (8%) of program storage space. Maximum is 253952 bytes.
Global variables use 1984 bytes (24%) of dynamic memory, leaving 6208 bytes for local variables. Maximum is 8192 bytes.
lasselukkari commented 3 years ago

For some reason the memory usage is a lot less when I compile for the Arduino UNO. Let's see if I can figure out the reason.

lasselukkari commented 3 years ago

Ok. So now I remember. It's been a while I since I have used the AVR boards myself. Uno is considered a low ram mcu in the code and some features are dropped/limited for that board. if you want to get the same thing happening for mega add this before you import the library:

#define LOW_SRAM_MCU
#include <aWOT.h>

After that change the result will be:

Sketch uses 21250 bytes (8%) of program storage space. Maximum is 253952 bytes.
Global variables use 896 bytes (10%) of dynamic memory, leaving 7296 bytes for local variables. Maximum is 8192 bytes.

I hope that is more acceptable.

lasselukkari commented 3 years ago

In the future this option will be called LOW_MEMORY_MCU instead of LOW_SRAM_MCU.