What type of memory am I using?

From here, I learned of 3 types of memory: Flash, SRAM, and EEPROM.

I am not using EEPROM. Flash is used to store the sketch, and the SRAM stores runtime "stuff".

In my sketch, in a global setting, I have the following line:

byte animation[2112];

In the loop function, I then have some simple networking that fills this array with values coming across the serial port.

My question: Is the information I sent into this 'animation' byte array stored in flash or SRAM?

I had assumed it was stored in SRAM since it was being filled during runtime, but I'm now wondering (since it compiles with the 2112 extra bytes in flash) if this data is stored in flash instead.

What Arduino board?

dynamic memory is not FLASH or EEPROM

Oddly, it appears to be both.

EDIT: OOPS! I just checked with a much smaller array size and the amount of FLASH used did not go down. It's just that a tiny sketch uses 2646 on a MEGA and 2306 on an UNO, regardless of the array size.

const int size = 2112;
byte animation[size];

void setup()
  for (int i = 0; i < size; i++)
    animation[i] = random(256);

void loop()
  unsigned long sum = 0;
  for (int i = 0; i < size; i++)
    sum += animation[i];

If you post your COMPLETE program, someone here can easily explain why you are seeing that FLASH usage. As explained, uninitialized data items will NOT consume any FLASH.

1 Like

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