Pointer memory allocation in function

2018-08-14 16:00:08

I would like to know how Arduino allocate memory for pointers in function arguments.

For instance. I have this code that use 192 bytes (Arduino IDE compiler:

Global variables use 192 bytes (9%) of dynamic memory).

char alph [] = {'a', 'b', 'c','\0'}; // 4 bytes

int numb [] = {1, 2, 3, 4}; // 8 bytes

float flo [] = {1.1, 2.2, 3.3}; // 12 bytes

void fn(){

Serial.println(alph);

Serial.println(numb[1]);

Serial.println(flo[1]);

}

void setup()

{

Serial.begin(9600);

fn();

}

void loop(){}

The following code is the same of above, but I'm using pointer to variables in arguments, that use 234 bytes (Arduino IDE compiller: Global variables use 234 bytes (11%) of dynamic memory).

char alph [] = {'a', 'b', 'c','\0'}; // 4 bytes

int numb [] = {1, 2, 3, 4}; // 8 bytes

float flo [] = {1.1, 2.2, 3.3}; // 12 bytes

void fn(char * _alph, int * _numb, float * _flo){

Serial.println(_alph);

Serial.println(_numb[1]);

Serial.println(_flo[1]);

}

void setup()

Serial.beg