I have this sketch:
const uint32_t len = 65536;
uint8_t arr[len];
void setup() {}
void loop() {}
The length of the array should fit into the dynamic memory. However, when I compile the sketch it says this in the output window:
Sketch uses 10528 bytes (0%) of program storage space. Maximum is 2031616 bytes.
Global variables use 13504 bytes (1%) of dynamic memory, leaving 1034224 bytes for local variables. Maximum is 1048576 bytes.
If I change len
to 10, that doesn't change. The compiler is set to "Debug", so it should not get optimized away. This indicates, that the memory isn't actually being allocated. What seems to be the problem here?
I am compiling for the Teensy 4.0, but the output is the same in essence for the Arduino Uno and other boards (with lower memory sizes).