Skip to content

Commit

Permalink
free JsonDocument for livedata as soon as possible
Browse files Browse the repository at this point in the history
  • Loading branch information
helgeerbe committed Mar 24, 2023
1 parent 3f8226c commit 7d48e42
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions src/WebApi_ws_live.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,14 +61,16 @@ void WebApiWsLiveClass::loop()
if (millis() - _lastWsPublish > (10 * 1000) || (maxTimeStamp != _newestInverterTimestamp)) {

try {
DynamicJsonDocument root(40960);
JsonVariant var = root;
generateJsonResponse(var);

String buffer;
if (buffer) {
// free JsonDocument as soon as possible
{
DynamicJsonDocument root(40960);
JsonVariant var = root;
generateJsonResponse(var);
serializeJson(root, buffer);
}

if (buffer) {
if (Configuration.get().Security_AllowReadonly) {
_ws.setAuthentication("", "");
} else {
Expand Down

0 comments on commit 7d48e42

Please sign in to comment.