diff --git a/src/WebApi_ws_live.cpp b/src/WebApi_ws_live.cpp index 20308d779..f3a427292 100644 --- a/src/WebApi_ws_live.cpp +++ b/src/WebApi_ws_live.cpp @@ -68,6 +68,14 @@ void WebApiWsLiveClass::loop() try { std::lock_guard 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);