Fix: Workaround: Don't allow memory intensive web functions in parallel

Somehow the API has to be adjusted to reduce memory consumption. For now lets just prevent both methods to allocate memory at the same time.
This commit is contained in:
Thomas Basler 2023-09-02 01:41:53 +02:00
parent 2c41be106e
commit b34b22c658
2 changed files with 6 additions and 2 deletions

View File

@ -25,4 +25,6 @@ private:
uint32_t _lastInvUpdateCheck = 0;
uint32_t _lastWsCleanup = 0;
uint32_t _newestInverterTimestamp = 0;
std::mutex _mutex;
};

View File

@ -62,7 +62,8 @@ void WebApiWsLiveClass::loop()
if (millis() - _lastWsPublish > (10 * 1000) || (maxTimeStamp != _newestInverterTimestamp)) {
try {
DynamicJsonDocument root(40960);
std::lock_guard<std::mutex> lock(_mutex);
DynamicJsonDocument root(4096 * INV_MAX_COUNT);
JsonVariant var = root;
generateJsonResponse(var);
@ -221,7 +222,8 @@ void WebApiWsLiveClass::onLivedataStatus(AsyncWebServerRequest* request)
}
try {
AsyncJsonResponse* response = new AsyncJsonResponse(false, 40960U);
std::lock_guard<std::mutex> lock(_mutex);
AsyncJsonResponse* response = new AsyncJsonResponse(false, 4096 * INV_MAX_COUNT);
JsonVariant root = response->getRoot();
generateJsonResponse(root);