Tipp and questions concerning memory usage.

I experienced some interesting things today. I wanted to do some kind of unit test outside of the Arduino IDE environment. Wrote a little arduino mock and put my implementations into header and cpp files. Did some #ifnef procedure to include Arduino if I compile in Arduino IDE and the other in g++.

In quant.cpp:

#include "quant.h"

#ifdef MOCK_ARDUINO
 #include "arduinomock.h"
#else
 #include "Arduino.h"
#endif

In .ino file:

#include "quant.h"'

After some makefile fixing so g++ worked it was time to compile in Arduino IDE (verify):

Sketch uses 2306 bytes (8%) of program storage space. Maximum is 28672 bytes.
Global variables use 163 bytes (6%) of dynamic memory, leaving 2397 bytes for local variables. Maximum is 2560 bytes.

I went back to my old solution with all in one .ino file and Compiled:

Sketch uses 7324 bytes (25%) of program storage space. Maximum is 28672 bytes.
Global variables use 414 bytes (16%) of dynamic memory, leaving 2146 bytes for local variables. Maximum is 2560 bytes.

As you can see the memory consumption from the Sketch has dropped significantly.
Is this just a measurement in Arduino IDE JUST for the Sketch, Arduino IDE ignores cpp and header files memory consumption?

OR

Is this a result of needing to remove magic things done by Arduino IDE? For instance I needed to define some stuff static when I used linker and other to make it compile under g++.

Maybe there's some aggressive optimisation going on.
Impossible me to say on the limited information available

Hi AWOL, thank you for the quick answer! Yes I know I don't give away allot of code here, it is not so well structure on this stage.... My question was more in a general manner of curiosity. The only thing I find doing some G.I. is About .INO and .CPP Files in Visual Micro and that is more in the aspect of function prototypes.

doing some G.I.

"gastro-intestinal"?

G.I. = Google.It. = trying not to be lazy. :slight_smile: