Periodic Flashing Cyan Photon After Several Days

I think I have this one solved. Thought I’d post it to give others a clue. It was definitely caused by a memory leak in the code and I have finally found the last little bit, I hope. The symptom is that the Photon would run just fine for several days then I’d discover it non-responsive and rapid flashing cyan. There would be no cloud activity either a Particle or Blynk. There is no way for me to know if there is Serial activity being mounted in an awkward place, but the application was definitely frozen.

Basically any bad management of character arrays result in a memory leak that probably interfere with Particle keys or such. Reset fixes it for another few days. The latest issue was that a String.reserve call was too small for the size of string I was assigning to it. That was particularly annoying because I knew I was doing the right thing with the memory approach but didn’t notice my reserve space was too small. Hopefully that will be the end of this.

When this runs for a month I’ll label it solved.

1 Like

UPDATE: It ran about 12 hours then crashed.

Using #ifdef I’ve commented out most of the bells and whistles that use memory functions (char*, new, delete) and set it off running in a bare bones mode. I’m now pursuing the theory that the code that I borrowed (gasp!) are creating the problem. Basically this application has three “nice-to-have” packages:

  • openweather + json lite (for OAT)
  • Blynk (for gui similar to particle cloud)
  • Particle (for cloud variables and functions)

Right now the Blynk stuff is the only thing running. Should take a day or two to run this test with whatever is causing this.

Does anybody reading this know: Is there an emulator for the Photon? Are there “electric fence” add-ons? PROGRAMMER SHIELD LOOKS TO BE THE ANSWER TO THIS. Why isn’t anybody responding? Holidays I guess.

UPDATE:
I got impatient and threw in some stress testing by increasing the frequency of operations. The result was that when openweathermap returned a different result the parse function in the borrowed code overflowed and slowed things way down. The result was rapid flashing cyan like I was looking for. I do not understand that borrowed code well enough to fix things: I tried making the <70> template size larger and that corrected the overflow but return values were now 0 instead of OAT. So I’ve disabled only the weather functions, allowing OAT=30, and set this off for a long run. So far - two days - all’s fine.