log if memory allocation for live view fails

Explained in #591
This commit is contained in:
helgeerbe 2024-01-04 15:38:28 +01:00
parent 4548fc2a00
commit 65319ed07e

View File

@ -68,6 +68,14 @@ void WebApiWsLiveClass::loop()
try {
std::lock_guard<std::mutex> lock(_mutex);
DynamicJsonDocument root(4200 * INV_MAX_COUNT); // TODO(helge) check if this calculation is correct
// TODO(helge) temporary dump of memory usage if allocation of DynamicJsonDocument fails (will be fixed in upstream repo)
if (root.capacity() == 0) {
MessageOutput.printf("Calling /api/livedata/status has temporarily run out of resources. Reason: Alloc memory for DynamicJsonDocument failed (FreeHeap = %d, MaxAllocHeap = %d, MinFreeHeap = %d).\r\n", ESP.getFreeHeap(), ESP.getMaxAllocHeap(), ESP.getMinFreeHeap());
_lastWsPublish = millis();
return;
}
JsonVariant var = root;
generateJsonResponse(var);