free JsonDocument for livedata as soon as possible

This commit is contained in:
helgeerbe 2023-03-24 15:39:03 +01:00
parent 3f8226c36c
commit 7d48e426dc

View File

@ -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 {