Program space with Device OS 1.4.1

Tags: #<Tag:0x00007fe21fe4fc88>


I am trying to write a simple program to check the maximum size of application program space or flash memory.

I can’t seem to get a const array created in flash of the size required? Ideas?

//Test application to check the limit of flash space with Device OS 1.4.1 and above on Photon
#include "Particle.h"


#define ARRAYSIZE 110000
const uint8_t array[ARRAYSIZE] = {1, };
void setup()
    while(!Serial.available()) delay(10);
    Serial.printlnf("Maximum program flash usage %i", sizeof(array));

void loop()


What does this mean exactly?
Compile time error?
Not able to flash?

Have you tried a smaller array?
107+KB is a stretch.


Neither, it compiles fine and I can flash but the flash usage is still 4%

Thus, it does not create an array in flash OR rather the compiler is optimizing the array?

107+KB is a stretch.

I thought the space available was 120KB (actually 128KB).


Since you are not using any of the array stored data the optimizer is clever enough to realise there is no need to actually create that array in flash :wink:

If you just add this in your code the optimizer is forced to do it

  for (int i = 0; i < sizeof(array); i++)

True, but I doubt you’ll be very happy with 100+KB static data and almost no flash left to store actually useful code :wink:

With this really minimalist code the max array size I could get to was 126562

void setup() {
  for (int i = 0; i < sizeof(array); i++)


Thanks, I am just trying to test some insight that the user application program space increased with 1.4.0 and above due to some optimisations that Brandon got put through to support the TensorFlow Lite Micro port.

The maximum size /flash that will compile is 131064 or 118.5% this is the same as with OS 1.3.1 so I guess no change then :frowning_face: