-
Notifications
You must be signed in to change notification settings - Fork 240
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
esp_wifi eventually uses up all available memory and stops working #2892
Comments
You can add logging of heap usage stats, which was added in PR #2619. This way, you will be able to notice memory leaks earlier |
I added heap logging every five minutes. I wouldn't say there is any obvious jump anywhere, it starts at 50% (49836/98304) then slowly rises. Once it reaches 70% (69180/98304) esp_wifi starts complaining about failing to allocate occasionally. It gets really bad once we get to 80% (78668/98304). Usage continues to grow though, up to 96% last I looked, |
Memory usage eventually hit 97% and the device stopped with a "Load access fault" |
I notice you have |
Sure, I think I was just randomly trying things to fix it. After about 30 minutes of running heap usage has risen by 2% which is about in line with previously. |
The memory usage doesn't seem related to network traffic. I tried changing my code such that it sends and receives data much more frequently. It does however appear related to losing the connection to the wifi AP. I ran a test where I watched the heap usage every 30 seconds and over the course of a few minutes the total heap usage was completely stable, however when I then forced the device to reconnect to the wifi (I can tell the AP to disconnect it) the heap started growing by about 30 bytes every 30 seconds. Reconnecting it a few more times didn't change that. |
Thanks for the hint regarding the reconnect.I think I found the reason for the leak and hope to have a fix soon |
Awesome. Let me know if you would like me to test anything. |
#2892 should fix the issue |
Awesome thanks. I can confirm that it solves the problem. My device has now been running for 20 hours and heap usage is exactly the same as when it started. Thanks for the quick fix! |
Bug description
I have a project I'm playing with on an ESP32C6 board to publish sensor readings to mqtt. I have everything working but after about 12 hours of operation the wifi stops working and I see repeated
Unable to allocate 2360 bytes
warnings from esp_wifi in the log. esp_alloc has 96K of heap space and to my knowledge nothing else beyond esp_wifi is using it. I've tried increasing that as much as I can but nothing helps.My repo is here: https://github.com/Mossop/garage-sensor.
Much of the esp-specific code is in here: https://github.com/Mossop/garage-sensor/blob/main/src/board/esp32c6.rs. Everything outside that uses the embassy_net APIs to interact with the network.
I have made some attempts to narrow the problem down but given the ~12 hour time to see if something works or not I haven't had much success. The basic embassy_net examples in the repo do not seem to do this. Is there some additional logging I can try to narrow down what might be going on?
Expected behavior
esp_wifi should not run out of memory.
Environment
The text was updated successfully, but these errors were encountered: