Replies: 9 comments 13 replies
-
@gluca : please format your pos accordingly next time to speed up the reading. We are all participating in our free time so anything helping us is appreciated. I took the liberty to reformat it. |
Beta Was this translation helpful? Give feedback.
-
@gluca : how did you do your tests ? ESP-IDF / LWIP layer use to allocate for the network buffers which are only freed after some time. We do some perf tests in the project with even concurrent requests and there are indeed some heap decrease during the test but the amount of heap recovers after it finishes (sometimes after some time). please add timestamps and wait a little more. I will move that to a support ticket. |
Beta Was this translation helpful? Give feedback.
-
Ok. I did some other tests. First i used a js to let firefox polls the esp32 and heap free space was not consuming. So i added a browser query (randomly) and it did happen again (see dump in attached file). Logging is every 5 seconds, js query is every 10 seconds, Manual query is random. Then I checked what firefox was asking differently when calling the url from the browser instead of JS. I found (hopefully) the culprit: When calling from the browser, firefox also asks the server for the favicon but on https! It gets a Network_Error (esp32 is not configured to answer https) but something is happening on ESP side and heap free space decreases (and memory is never recovered, at least after 1500s from the last call). Now I am preparing new test using js to ask for a resource on https using other browsers as well to have a confirmation of that behavior, but I suspect something happen in the handshake part for SSL that makes ESP32 to allocate some memory that get wasted. |
Beta Was this translation helpful? Give feedback.
-
Ok. Here we are. I've attached the arduino sketch that recreates the problem. After upload the sketch to the ESP and waited it connects to wifi, point any browser to http://<ESP_IP_ADDRESS>:8080/client.html Tests I've made with both Firefox and Chrome reveal the issue (now i am sure is an issue) firefox produces a way bigger memory leak, something around 6K per query, while chrome is around 1.3k per query. Not sure if is a problem of ESPAsyncWebServer or of AsyncTCP library. I have last (in the arduino repos) version of both. |
Beta Was this translation helpful? Give feedback.
-
Can you tell me exactly what are the dependencies you are using, and if you are using Platformio ? Or, if you are using Arduino IDE, how are you making sure that the libraries compiled are the most recent ones (asking since Arduino IDE has a really poor dependency management system). Thanks!
How is that possible ? When you open port 8080, only 8080 is opened, so the ESP (more precisely AsyncTCP) does not answer on any other port. The browser would need to call https://ip:8080 to ask for a resource with ssl protocol on rhe same non-ssl port, which I doubt it does. |
Beta Was this translation helpful? Give feedback.
-
use the sketch i provided, is all there.
When asking for a resource in http, on the background firefox try to get favicon on the same port using **HTTPS** protocol.
The example i provided implements this behavior. It alternates http calls to https calls on the same port.
As you can also see from the output i provided, on http calls memory is
handled properly while trying https on same port leads to memory leaks, 6k using firefox and 2k using chrome.
Platform iuse is arduino ide 2.3.6 and the libraries used are the last one available there:
AsyncTCP 3.4.6
ESPAsyncWebServer 3.7.10
I guess problem arise when initiating ssl handshake (from client side) and something happen server side that produce that leak.
Don't know if in AsyncTVP or ESPAsyncWebServer.
You can also replicate the same behavior setting a js calling the server and asking any resource (even invalid one) with https instead of http (it also works using browser normally).
|
Beta Was this translation helpful? Give feedback.
-
I am a grumpy old (ex) developer... No way I desist :-D
|
Beta Was this translation helpful? Give feedback.
-
Will be fixed in main once PR #255 will be merged |
Beta Was this translation helpful? Give feedback.
-
Teested with AsyncTcp 3.4.7 and it works as expected |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Platform
ESP32
IDE / Tooling
Arduino (IDE/CLI)
What happened?
Free memory heavy reduction after each client request until crash. The effect is huge using firefox as browser while is relatively small using chrome.
Each time you request any URL (in the example i made 2 hooks, one for "/" and one for all others (not found) pages) the free memory in heap reduces drastically, using firefox as client browser (roughly 5 to 6kbytes for each request). Using chrome the heap size reduction is less evident but still here (500 to 600 bytes with recovery), as you can see from Serial output i provided and that can be reproduced by my example code.
Stack Trace
No Stack trace until it crashes for out of memory. Output of main loop (showing memory degradation) follows:
Chrome (Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/138.0.0.0 Safari/537.36)
Minimal Reproductible Example (MRE)
I confirm that:
Beta Was this translation helpful? Give feedback.
All reactions