-
Notifications
You must be signed in to change notification settings - Fork 7.6k
HTTP Client Error 105, and then, Memory Leak when using FreeRTOS #8804
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
Comments
I have been testing the behaviour of this issue a little bit more. Reusing the same HTTPClient to make different request does not cause a memory leak, there might be a problem with the destructor. |
@lucasssvaz PTAL |
Hmm reading the original issue again, it seems like this issue is about the WiFi client. Not 100% sure whether it is the same issue..... |
memory returning back is normal. Some connections are kept in cache for a bit in case of reconnect, etc. |
Is this configurable, as the behavior was different on older IDF versions? (Assuming this is the same issue as reported by the OP, as he didn't report memory is recovered after some time) |
This has always been like that. It's part of TCP. Depending on who closes the connection and how, it might be kept in memory for a bit. |
So what are the methods "setReuse", and "end" in case of the HTTP client or "stop" in case of the Wifi client meant to be used for? |
why? it does not use a lot of memory and it has a limited amount of connections that it will cache. We used to hack this in 8266, but here we have plenty more RAM to stay standard |
it is possible that on the 2.x Arduino there could be different settings on the different chips. We have "fixed" this in 3.0.0. Any chance you give the Alpha2 a go? |
@Jason2866 What framework build of yours is using the Alpha2? Edit: C3 hit with about 5.6 JSON requests being handled per second: On ESP32 with Ethernet (about 6.5 requests per sec) is the impact less as you only seem to loose about 40k of RAM instead of 125k on the C3: On ESP32-S2 the behavior is completely different. ESP32-S3 is showing similar behavior as the S2: (running 8 browser tabs fetching the same JSON every second, still running at time of screenshot) |
The framework is built with latest Arduino and IDF5.1 release branch commits. |
What settings are changed, which can introduce this behaviour? |
@Jason2866 made a platform_package for me with some changes to the MSL and FIN wait timeout.
This does make the problem much less of a problem, but I wonder if this is a proper fix or could it have unforeseen side-effects? @s-hadinger rightfully outed his concerns about this suggested change as he still believes there must be something wrong (or changed for unknown reason) causing connections not to be closed when they should. |
Hello, Due to the overwhelming volume of issues currently being addressed, we have decided to close the previously received tickets. If you still require assistance or if the issue persists, please don't hesitate to reopen the ticket. Thanks. |
Board
Adafruit ESP32 Feather - HUZZAH32 / ESP32-MINI-1
Device Description
Plain module on breadboard: HUZZAH32, and ESP32-MINI-1 in custom board
Hardware Configuration
Nothing relevant
Version
v2.0.14
IDE Name
Arduino IDE
Operating System
Ubuntu 22.04 with Kernel 5.15.0-87-generic
Flash frequency
80MHz
PSRAM enabled
yes
Upload speed
921600
Description
Using the HTTP Client inside loop does not cause any issues., whereas using it inside a task raises error 105 after the request number 16.
This is due to a bad implementation of the HTTPClient::disconnect method, where the _client stop method is not called if the is released if the _client used is not avaliable or connected, as it can be seen in code. This can be solved by adding a call to _client->stop() in line 408. This causes the client used to close the openned socket, thus allowing to create a new one.
Despite fixing that, also, only when running the HTTP client in a task, I see that in each one of the executions of my task, there is memory allocated in the heap that does not get released. Around 200 bytes get used in each one of the requests executed.
This issue is similar to #5072, with the difference that the issue mentioned in it is "solved" (if you guys agree, I can make a push request with my changes), but with the additional issue of the memory leak, which I have not found the reason of it.
Sketch
Debug Message
Other Steps to Reproduce
The problem occurs either in the HUZZAH 32 and my custom board.
I have checked existing issues, online documentation and the Troubleshooting Guide
The text was updated successfully, but these errors were encountered: