-
-
Notifications
You must be signed in to change notification settings - Fork 345
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
Memory leak in MqttClient connect #1740
Comments
I guess the following is happening:
The queue gets slowly filled with messages to be sent. All of them are waiting for a connection and thus requiring memory. At some point the memory just is not enough to hold all of them and thus your ESP12-F runs out of memory. There are multiple ways how to solve this. One of them can be that we put a limit on the number of messages, or the total size in bytes of the messages, that can wait in the queue when the client is not connected. This way the client can accept, for example, max 3 messages and discard the rest. If we go for the items size or items memory limit in a queue then we should apply this also to the SmtpClient, HttpClient and others that queue items before sending them. |
Thanks for looking into it but as statetd in the post I removed the call to And sorry for the screwed up indetation in the code which really didn't improve readbility :( |
That code should be compilable and runnable also in the Host Emulator. That means that you can yourself analyze the memory usage using valgrind. The latter will catch easily any memory issues. Or wait for me but that can take quite some time... |
It seems that that trying to connect with
MqttClient
causes a memory leak. When the MQTT broker is not reachable and then retrying regularly then at some point you run out of heap.Should be easily reproducible with the sample
MqttClient_Hello
. While I used this exact code (basically only publish removed):Output is this:
Done on Sming 3.8.0 on an ESP12-F.
The text was updated successfully, but these errors were encountered: