Also reboot if no heap debugging enabled

This commit is contained in:
Thomas Göttgens 2023-01-23 22:20:34 +01:00
parent e8186f7dba
commit 19d864b5ce

View File

@ -1,7 +1,8 @@
#include "OSThread.h" #include "OSThread.h"
#include "configuration.h" #include "configuration.h"
#ifdef DEBUG_HEAP #ifdef HAS_SCREEN
#include "graphics/Screen.h" #include "graphics/Screen.h"
#endif
#include "main.h" #include "main.h"
#endif #endif
#include <assert.h> #include <assert.h>
@ -83,18 +84,21 @@ void OSThread::run()
#endif #endif
currentThread = this; currentThread = this;
auto newDelay = runOnce(); auto newDelay = runOnce();
#ifdef DEBUG_HEAP #ifdef ARCH_ESP32
auto newHeap = ESP.getFreeHeap(); auto newHeap = ESP.getFreeHeap();
if (newHeap < 10000) {
LOG_DEBUG("\n\n====== heap too low [10000] -> reboot in 5s ======\n\n");
#ifdef HAS_SCREEN
screen->startRebootScreen();
#endif
rebootAtMsec = millis() + 5000;
}
#ifdef DEBUG_HEAP
if (newHeap < heap) if (newHeap < heap)
LOG_DEBUG("------ Thread %s leaked heap %d -> %d (%d) ------\n", ThreadName.c_str(), heap, newHeap, newHeap - heap); LOG_DEBUG("------ Thread %s leaked heap %d -> %d (%d) ------\n", ThreadName.c_str(), heap, newHeap, newHeap - heap);
if (heap < newHeap) if (heap < newHeap)
LOG_DEBUG("++++++ Thread %s freed heap %d -> %d (%d) ++++++\n", ThreadName.c_str(), heap, newHeap, newHeap - heap); LOG_DEBUG("++++++ Thread %s freed heap %d -> %d (%d) ++++++\n", ThreadName.c_str(), heap, newHeap, newHeap - heap);
#endif
if (newHeap < 10000) {
LOG_DEBUG("\n\n====== heap too low [10000] -> reboot in 5s ======\n\n");
screen->startRebootScreen();
rebootAtMsec = millis() + 5000;
}
#endif #endif
runned(); runned();