OK, the photon running my application is freezing after about 1.5 days. Actually, the last reset, which just occurred an hour ago, was caused by a watchdog reset. The RGB LED was breathing green, and after a 60 second timeout, the watchdog issued a system.reset.
Before I got rid of any String class usage, the watchdog would not reset the photon after 1.5 days, most likely caused by heap fragmentation due to so much dynamic memory allocation.
So, I started commenting out large swathes of code in my application, and I kept seeing this 1264 byte difference coming and going when calling freeMemory() even after everything was commented out.
So, I wrote the following test code:
uint32_t free_memory = 0;
free_memory = System.freeMemory();
if (free_memory < 61500)
Serial.println("Where is the memory going?");
Using a console to read the output from the serial connection, you'll see after about 20 seconds, the "Where is the memory going?" string appear, and the amount of available memory will drop by 1264 or even some multiple of 1264. I've seen it drop by 2528 a couple times. Looks like it coincides with the Photon losing its cloud connection because I'm not using Particle.process(). Even if you add Particle.process() at the end of loop(), you'll still see the 1264 bytes disappearing and reappearing in freeMemory().
It wasn't until my application grew to a point where freeMemory() normally reads at 43kb that I started seeing intermittent issues with the photon freezing. So, I'm guessing that most folks using Photons probably won't experience this issue unless their application's memory needs get large.
I think that I probably have a memory leak somewhere in my application that will break the application after about a 1.5 days. However, I'd like to understand what's going on in the background that's causing freeMemory to fluctuate.
@KyleG, could you forward this along to the appropriate Particle team member?