For months now, something in my code has caused loop() to hang a few times a day. I use a watchdog to reboot the system in this event, but I’d love to properly fix the bug. I have plenty of debug Serial prints but don’t see an obvious pattern/culprit. What is the best practice here? Is there a way to use the watchdog to track what function gets caught in a loop or is the last one called, or if there’s a memory issue?
My code is 6000+ lines and employs several libraries, so I don’t expect anyone to examine it, but it’s up on GitHub if you’re curious.
Since trying to debug this, I’ve enabled the system thread but that has no effect besides allowing the device to maintain its connection to the cloud.
I’ve read that Strings can cause memory problems, and my code makes extensive use of them. Is converting as many of these as possible to char arrays the first order of business?
I have noticed that disabling the Webserver library and corresponding code appears to greatly diminish the frequency of the problem (if not remove it entirely), but I need to research this more. I don’t know if this simply frees up memory or actually keeps an offending process from running.