-
-
Notifications
You must be signed in to change notification settings - Fork 225
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
High Heap Fragmentation with 2 inverters #768
Comments
Eine Kleinigkeit die mir beim Code-Review aufgefallen ist: Die JSONDocument Dokumentation schlägt vor, für kleine Jsons StaticJsonDocument zu verwenden, siehe https://arduinojson.org/v6/api/jsondocument/:
In pubMqtt.h werden aber DynamicJsonDocument benutzt, von 128-256 Byte Größe. Wie wäre es mit folgendem Patch:
Note, auch das dynamische hat eine feste Größe: https://arduinojson.org/v6/api/dynamicjsondocument/
|
so wie ich es gelesen habe ist der Unterschied die |
Ja genau. Und viele kleine JsonDocument auf dem heap (dynamic, jetztiger Code) zerlöchern doch auch den Heap, oder? Deswegen schlägt die Doku ja vor, kleine JsonDocument statisch zu bauen, die landen dann auf dem Stack (mein diff). Vielleicht machts ja ne Verbesserung? Ich kann's morgen mal ausprobieren wenn die Sonne wieder scheint (mit zwei Invertern). Edit: Gerade dein Edit über die |
Das ePaper hat aber nichts damit zu tun ? 🤔 |
Dann würde das Problem doch bei
Dann mal sehen, ob der heap immer noch so löchrig wird. |
I tried to implement some of the improvements discussed in this thread. Patch attached. I will report after a long-term test.
|
@Argafal good approch, but I'm afraid that the array @lumapu btw. there's quite a lot functions where a |
good point 👍 |
sorry I don't know, but shouldn't it be possible to determine the maximum length needed whenever |
Agreed. Of course the really issue is that MQTT_TOPIC_LENGTH is not what it says it is. It's not the maximum topic length of our MQTT messages. Instead it's the maximum length of the mqtt prefix, right? For now I have made the proposed change and added it to the pull request. We might consider some cleaning up here, too, but this corrects the immediate length issue.
I saw that and I agree that that should be changed, too. |
Zum Testen hab ich mal alle debug statements entfernt. Das kann man recht schnell mit folgendem Kommando erledigen: Der heap fragmentation Wert wird etwas kleiner, aber nicht viel. Er geht bei mir von 29 nach 27. Ein kleiner Erfolg. Meiner Meinung nach könnte man also versuchen, die Debug-Strings noch ein klein wenig zu optimieren. Unglaublich viel Zeit sollte man da aber auch wieder nicht rein stecken, denn der Nutzen is begrenzt. Wichtiger wäre es zu verstehen, woher der große Anteil heap fragmentation kommt. In der MQTT Lib dir wir benutzen wird, wenn ich das richtig verstehe, für jede Nachricht eine Kopie erzeugt. Diese Kopie wird mit malloc gemacht, und dann asynchron verschickt, Speicher dann wieder freigegeben. Ob das stark zur heap fragmentation beiträgt? Gibt es keine MQTT lib die mit einem festen/Ring-Puffer arbeitet und die speziell für ESP8266 gedacht ist? Oder benutzen wir die MQTT lib vielleicht falsch? |
es gibt meines Wissens synchrone und asynchrone Beispiele für den Einsatz der Lib. |
wenn die MQTT Lib für's
|
Könnten Betroffene (und auch Nicht-Betroffene) bitte kurz diese Fragen beantworten:
|
nicht betroffen 😎
|
Ich beantworte mal selbst für meine Situation:
ESP8266
0.1.105 mit einem privaten Patch der testweise alle Debugging-Nachrichten aus dem Code entfernt
Zwei. HM-600 und HM-1500.
30s. 5 retries
ja
Raspberry Pi Zero v1
0
ja
27
ja, bei aktiver WebUI Nutzung. Ansonsten stabil wie ein Stein. |
hab' ESP32 und keine Probleme, Testet doch mal mit Inverter Settings 'Max retries per Payload' = 0. Dann gibt's zwar weniger Intervall-Updates (es sei man verkürzt das Abfrage Intervall), aber vielleicht funktioniert WebUI dann besser. |
@beegee3 hast du dazu auch eine nachvollziehbare Erkärung? Denkst du eher an unseren Code (RX-loop in |
@lumapu na ja, wenn retransmits erforderlich sind, werden diese sofort angestoßen, d.h. direkt mit dem nächsten Aufruf von |
hier mal der |
nein noch nicht, steht aber auf meinem Plan. Kann mir schon vorstellen, dass es was bringt. |
@beegee3 die Änderung hat's echt gebracht, heap fragmentation auf |
nach einem OTA Update ist die fragmentation auch wieder bei 34. Ein weiterer Reboot bereinigt das. Ich erkläre das damit, dass beim Booten das Update entpackt wird und dabei der Heap versaut wird. |
@lumapu 🎉 👍 Danke zur Version 0.6.0 !!! Zwei Fragen hätte ich bei der Gelegenheit noch (will aber nicht nerven, reine Neugier 😁):
|
ich mache hier mal zu. Beim ESP8266 gilt weiterhin: nach einem Update nochmal einen Reboot machen, dann sollte die Heap-Fragmentation < 10 sein. |
Die Heap Fragmentation ist auch in Version
0.5.100
und zwei konfigurierten Invertern sehr hoch (beim ESP8266~36
).Wenn der zweite Inverter nicht aktiviert aber konfiguriert ist, bleibt das Problem bestehen. Mit nur einem Inverter ist die Fragmentation bei
2
.(Jetzt wieder mit 2 Invertern)
Wird in
pubMqtt.h
mClient.loop()
auskommentiert, dann geht die Heap Framentation auf~14
.@beegee3: Hast du eine Idee woran das liegen könnte? Ich glaube man muss jetzt eher Richtung
hmSystem.h
undhmInverter.h
schauen.Für mich soll der Issue als Gedankestütze dienen. Evtl. hat jemand einen guten Input was die Ursache sein könnte.
The text was updated successfully, but these errors were encountered: