-
-
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
Frequent mqtt publish eats heap #1576
Comments
I have a similar problem but only when there is no internet. The getConnectionState function takes around 10 minutes to identify that the internet is down, so depending on the frequency that you publish your messages it will consume a lot of heap mem. The upside of this is that when it identifies that there is no internet the heap memory is freed. |
Sming is an async framework. The publishing of the message is not done immediately. If you push stuff into the internal buffer it will start to grow. Only when the TCP stack is ready to send data then part of that data will be delivered. And the buffer will decrease. If you fill the buffer faster then it is decreased (or emptied) then you will end up eating all available memory. It would be probably better to send a message with QoS 1 or 2. Wait for the confirmation and once it arrives send the next message. |
What you mention makes sense, especially when I read about mqtt QoS levels. Also some ideas for tuning the TCP stack parameters? (Just for the record). |
Hello.
I have a problem that is probably related to String.
If the code is executed each second, the heap gets exhausted in few minutes. About a kB each few tens of seconds.
If the timer is increased to two seconds, then the heap stays at almost constant value (currently at 38856 for few minutes already).
I think that I saw somewhere through the issues a similar problem, but can't recall the topic.
Here is the code.
PS: I tried to pass the strings by reference, but this doesn't change anything.
PS2: I tried to track down if some memory is allocated within the mqtt class and couldn't resolve how this code releases the memory. However it should work properly since my other projects work fine.
MqttClient.cpp
At the end - heap is still at 38856...
The text was updated successfully, but these errors were encountered: