Photon working both online and offline

thanks for the reply @ScruffR, what do you mean by revisiting that?
I really dont have any clue why my RAM is so low. I do have a String here and there that I will change to char, id appreciate some help for doing this.

The softAP uses a lot of ram too.

Any comments on the how NOT to use SYSTEM_THREAD(ENABLED) and still have the photon work when offline?

here is the code that generates the backups that I store in ram when the device has no internet:

#define ARRAYSIZE 200
String backup[ARRAYSIZE];
String payload;
for(int o=0;o<=ARRAYSIZE-1;o++){

            if(backup[o]=="x")      //all start with "x"
            {
                payload = String::format(  "{\"Timestamp_Device\":\"" + String(currentTime) + "\",\"device_id\":\"" + String(id.c_str()) +  "\",\"temp\":\"" + String(flowtemp1) + "\",\"flowshort\":\"" + String(flowtotal) +  "\",\"flowacum\":\"" + String(flowacum) + "\",\"vbat\":\"" + String(vbat) + "\",\"counterstatus\":\"" + String(counterstatus)+"\"}");
                if(config==1){    backup[o] = payload;}
                backup[o+1]="x";
                Serial.print("backup: ");Serial.print(o);Serial.print(" saved:  "); 
                Serial.print(backup[o]); Serial.println(" ");
                
                if(o==ARRAYSIZE-3){                 //if getting close to the limit delete everything . Id prefer to replace only the first..
                    cleanbackup();    //resets all to "x"
                    backupcounter=0;
                }
                else { o=ARRAYSIZE+1; }
                backupcounter++;
                
                freemem = System.freeMemory();
                Serial.print("free memory: ");
                Serial.println(freemem);
            }
        }

How can I store these payloads without having to declare the size of an array? How to declare it as string but still publish the data in the same format so that the webhook that receives it still works?

thanks!