-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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 when connect() #673
Comments
Arduino Core 2.5.2 |
I seems to have a similar issue but on the long run, it seems to be after around 24 hours of running, i don't know why, it try to reconnect and it jam in the connect function and never get out of there, i don't exactly know what is happening since i don't get any error, the watchdog on my esp32 doesn't kick. Everything just stop!? |
The PubSubClient code is very stable and has not changed for some time. No-one else has seen this issue, so there must be something about your sketch, or the particular network client you are using. Looking at your code (which you've sent me via email) to see where you are allocating additional memory each time it connects I can see you are creating a new instance of the |
Well, I have some reports of users with poor WiFi connections, stating when MQTT (thus this library) is used, they run out of memory and thus crash. (example: letscontrolit/ESPEasy#2684 ) About recreating the WiFiclient. That's also what I'm doing and was suggested here: esp8266/Arduino#4497 (comment) So I will also have a look at the progress of this issue. |
Newbie so plz correct me if I am wrong to comment on this issue it may be a different issue but is related to esp32 and connect().
Solved it by using a flag instead of trying to connect it in the if loop , I am not sure if this method is correct.Please correct me if i am wrong . As of now it is working fine probable i will test it this week and post if there is some problem.
|
Can you use 3 backticks at begin and end of a code block? |
Thx corrected it |
Hi
following the sample, I noticed that the library uses 1KB aprox of heap every time I call connect()
so for example:
void loop()
{
...
if ( !pubSubClient.connected()) {
mqttConnect();
}
...
}
and
void mqttConnect()
{
...
if (pubSubClient.connect(clientid, user, password)) {
...
}
else
{
...
}
...
}
It means that every time my router lost tinternet connection, pubSubClient.connected() is FALSE, mqttConnect() is called and THEN it butns 1KB of heap every time, without releasing the OLD memoty
How can I solve the issue?
Thannks
The text was updated successfully, but these errors were encountered: