-
Notifications
You must be signed in to change notification settings - Fork 7.4k
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
HTTPClient leaking memory? #3679
Comments
A possible locus: in your code you use |
@stickbreaker I agree that there is no free() for the malloc() in _streamLoad(). I am also surprised of the variable static char *dest = nullptr being local to the function _streamLoad(). Should be a private class variable and properly destructed. However, I do not call loadCACert(), do this bug is not the cause of the leak. Also, I have the impression that a lot of memory is leaked on a failed connection (~2k), causing the next call to GET to fail, but I am not sure yet. Maybe I can drop some debug info of another sketch (too big and to specialized to publish) that uses a PUT that fails first on the certificate that can not be verified and next on a lack of memory. No time tonight, so maybe tomorrow. |
My read through of Chuck. |
clientSocketHande and _rxBuffer are std::shared_ptr, the stop() call was not correctly releasing them and the operator= had similar problems fix for #3679
@Jeroen88 can you try branch stickbreaker-patch-3? I think I found the Memory Leak. Chuck. |
@stickbreaker thnx Chuck, I have a look at it later today! |
* std::shared_ptr Memory Leak clientSocketHande and _rxBuffer are std::shared_ptr, the stop() call was not correctly releasing them and the operator= had similar problems fix for #3679 * operator= second attempt * operator= third time
@stickbreaker your PR may be right, I did not check it, but it did not solve my problem. Your solution is in WiFiClient::stop() and I use a WiFiClientSecure. I double checked, although WiFiClientSecure is a public WiFiClient, the base WiFiClient::stop() is never called from WiFiClientSecure::stop(). It must be something else... |
Closing, because I found out that after 11 iterations the free heap stabilizes. |
Hardware:
Board: ESP32 NodeMCU
Core Installation version: ?1.0.0? ?1.0.1-rc4? ?1.0.1? ?1.0.1-git? ?1.0.2? ?1.0.3?
IDE name: Arduino IDE
Flash Frequency: 80Mhz
PSRAM enabled: no
Upload Speed: 921600
Computer OS: Ubuntu
Description:
I believe HTTPClient is leaking memory. The sketch I provide here is the BasicHttpsClient example from the library. I set debug level to verbose and removed all of the debug info, except for the line:
[V][ssl_client.cpp:59] start_ssl_client(): Free internal heap before TLS 262632
The Free internal heap before TLS drops at each iteration (see debug lines below):
-/- 376 bytes
-/- 104 bytes
-/- 100 bytes
-/- 96 bytes
-/- 96 bytes
-/- 96 bytes
-/- 96 bytes
-/- 96 bytes
-/- 96 bytes
Sketch: (leave the backquotes for code formatting)
Debug Messages:
The text was updated successfully, but these errors were encountered: