Program and global variable storage

Apologies in advance for such a basic question... why does this global array "x" not consume any global variable (or program) storage?

char x[20000];

void setup() {
  // put your setup code here, to run once:
}

void loop() {
  // put your main code here, to run repeatedly:
}

After compilation:

Sketch uses 6944 bytes (2%) of program storage space. Maximum is 262144 bytes.
Global variables use 3044 bytes (4%) of dynamic memory, leaving 62492 bytes for local variables. Maximum is 65536 bytes.

Because you haven't used it for anything. The compiler optimizes the code, if anything is not used, it doesn't allocate memory or code space for it.

Ah, thanks, adding

x[0] = 'a';

inside the loop forced the allocation:

Global variables use 23044 bytes...

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.