Closed arthurkafer closed 4 years ago
I saw something about the memory leak on #900, but in my example I'm just calling init
and deinit
. Other possible issue is this one, but I couldn't change anything on the raw library to make the results better.
I'm seeing similar behaviour: I'm alternating between WiFi and BLE (to make sure enough heap is available in both situations). After every BLE-Iteration the heap decreases until the ESP crashes.
I tested with code from OP and here is result:
15:47:41.341 -> ets Jun 8 2016 00:22:57
15:47:41.341 ->
15:47:41.341 -> rst:0x1 (POWERON_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)
15:47:41.341 -> configsip: 0, SPIWP:0xee
15:47:41.341 -> clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
15:47:41.341 -> mode:DIO, clock div:1
15:47:41.341 -> load:0x3fff0018,len:4
15:47:41.341 -> load:0x3fff001c,len:1216
15:47:41.341 -> ho 0 tail 12 room 4
15:47:41.341 -> load:0x40078000,len:9720
15:47:41.341 -> ho 0 tail 12 room 4
15:47:41.341 -> load:0x40080400,len:6352
15:47:41.341 -> entry 0x400806b8
15:47:42.367 -> 189016
15:47:42.367 -> BLE_OFF()
15:47:42.566 -> 274860
15:47:42.566 -> NEW_INIT()
15:47:43.131 -> 189024
15:47:43.131 -> BLE_OFF()
15:47:43.364 -> 274868
15:47:43.364 -> NEW_INIT()
15:47:43.929 -> 189024
15:47:43.929 -> BLE_OFF()
15:47:44.127 -> 274712
15:47:44.127 -> NEW_INIT()
15:47:44.693 -> 188876
15:47:44.693 -> BLE_OFF()
15:47:44.892 -> 274716
15:47:44.892 -> NEW_INIT()
15:47:45.491 -> 188876
15:47:45.491 -> BLE_OFF()
15:47:45.691 -> 274716
15:47:45.691 -> NEW_INIT()
15:47:46.256 -> 188888
15:47:46.256 -> BLE_OFF()
15:47:46.456 -> 274712
15:47:46.456 -> NEW_INIT()
15:47:47.056 -> 188868
15:47:47.056 -> BLE_OFF()
15:47:47.255 -> 274716
15:47:47.255 -> NEW_INIT()
15:47:47.821 -> 188888
15:47:47.821 -> BLE_OFF()
15:47:48.054 -> 274712
15:47:48.054 -> NEW_INIT()
15:47:48.619 -> 188864
15:47:48.619 -> BLE_OFF()
15:47:48.819 -> 274716
15:47:48.819 -> NEW_INIT()
15:47:49.384 -> 188884
15:47:49.384 -> BLE_OFF()
15:47:49.617 -> 274712
15:47:49.617 -> NEW_INIT()
15:47:50.184 -> 188868
15:47:50.184 -> BLE_OFF()
15:47:50.383 -> 274716
15:47:50.383 -> NEW_INIT()
15:47:50.948 -> 188884
15:47:50.948 -> BLE_OFF()
15:47:51.181 -> 274712
15:47:51.181 -> NEW_INIT()
15:47:51.713 -> 188868
15:47:51.713 -> BLE_OFF()
15:47:51.980 -> 274716
15:47:51.980 -> NEW_INIT()
15:47:52.545 -> 188884
15:47:52.545 -> BLE_OFF()
15:47:52.744 -> 274712
15:47:52.744 -> NEW_INIT()
15:47:53.309 -> 188868
15:47:53.309 -> BLE_OFF()
15:47:53.542 -> 274716
15:47:53.542 -> NEW_INIT()
15:47:54.107 -> 188884
15:47:54.107 -> BLE_OFF()
15:47:54.306 -> 274712
15:47:54.306 -> NEW_INIT()
15:47:54.904 -> 188868
15:47:54.904 -> BLE_OFF()
15:47:55.104 -> 274716
15:47:55.104 -> NEW_INIT()
15:47:55.702 -> 188884
15:47:55.702 -> BLE_OFF()
15:47:55.934 -> 274712
15:47:55.934 -> NEW_INIT()
15:47:56.500 -> 188872
15:47:56.500 -> BLE_OFF()
15:47:56.732 -> 274720
15:47:56.732 -> NEW_INIT()
15:47:57.298 -> 188876
15:47:57.298 -> BLE_OFF()
15:47:57.497 -> 274712
15:47:57.497 -> NEW_INIT()
15:47:58.062 -> 188880
15:47:58.062 -> BLE_OFF()
15:47:58.261 -> 274716
15:47:58.261 -> NEW_INIT()
15:47:58.859 -> 188880
15:47:58.859 -> BLE_OFF()
15:47:59.058 -> 274712
15:47:59.058 -> NEW_INIT()
15:47:59.691 -> 188872
15:47:59.691 -> BLE_OFF()
15:47:59.891 -> 274716
15:47:59.891 -> NEW_INIT()
15:48:00.459 -> 188876
15:48:00.459 -> BLE_OFF()
15:48:00.691 -> 274712
15:48:00.691 -> NEW_INIT()
15:48:01.256 -> 188880
15:48:01.256 -> BLE_OFF()
15:48:01.455 -> 274716
15:48:01.455 -> NEW_INIT()
15:48:02.019 -> 188876
15:48:02.019 -> BLE_OFF()
15:48:02.218 -> 274712
15:48:02.218 -> NEW_INIT()
15:48:02.817 -> 188880
15:48:02.817 -> BLE_OFF()
15:48:03.084 -> 274716
15:48:03.084 -> NEW_INIT()
15:48:03.649 -> 188880
15:48:03.649 -> BLE_OFF()
15:48:03.848 -> 274712
15:48:03.848 -> NEW_INIT()
15:48:04.414 -> 188876
15:48:04.414 -> BLE_OFF()
15:48:04.646 -> 274716
15:48:04.646 -> NEW_INIT()
15:48:05.211 -> 188880
15:48:05.211 -> BLE_OFF()
15:48:05.411 -> 274712
15:48:05.411 -> NEW_INIT()
15:48:06.009 -> 188876
15:48:06.009 -> BLE_OFF()
15:48:06.208 -> 274716
15:48:06.208 -> NEW_INIT()
15:48:06.772 -> 188880
15:48:06.772 -> BLE_OFF()
15:48:07.005 -> 274712
15:48:07.005 -> NEW_INIT()
15:48:07.602 -> 188880
15:48:07.602 -> BLE_OFF()
15:48:07.801 -> 274716
15:48:07.801 -> NEW_INIT()
15:48:08.366 -> 188876
15:48:08.366 -> BLE_OFF()
15:48:08.599 -> 274712
15:48:08.599 -> NEW_INIT()
15:48:09.162 -> 188880
15:48:09.162 -> BLE_OFF()
15:48:09.362 -> 274716
15:48:09.362 -> NEW_INIT()
15:48:09.926 -> 188876
15:48:09.926 -> BLE_OFF()
15:48:10.158 -> 274712
15:48:10.158 -> NEW_INIT()
15:48:10.788 -> 188872
15:48:10.788 -> BLE_OFF()
15:48:10.987 -> 274716
15:48:10.987 -> NEW_INIT()
15:48:11.586 -> 188880
15:48:11.586 -> BLE_OFF()
15:48:11.784 -> 274712
15:48:11.784 -> NEW_INIT()
15:48:12.348 -> 188876
15:48:12.348 -> BLE_OFF()
15:48:12.547 -> 274716
15:48:12.547 -> NEW_INIT()
15:48:13.146 -> 188880
15:48:13.146 -> BLE_OFF()
15:48:13.345 -> 274712
15:48:13.345 -> NEW_INIT()
15:48:13.908 -> 188876
15:48:13.908 -> BLE_OFF()
15:48:14.174 -> 274716
15:48:14.174 -> NEW_INIT()
15:48:14.738 -> 188884
15:48:14.738 -> BLE_OFF()
15:48:14.970 -> 274716
15:48:14.970 -> NEW_INIT()
15:48:15.535 -> 188884
15:48:15.535 -> BLE_OFF()
15:48:15.735 -> 274716
Not even a single byte leaking anymore.
Sorry for the confusion: I got the same problem using the BLEDevice implementation in arduino-esp32. During my debugging/gooleing session I must have gotten confused and didn't realize this was a different repo.
Anyone found solution for ble init / deinit leaking problem?
@peter1a It is a repository problem, you should use the library from here
I don't get it. If I go to that link I see this.
The actual source of the project which is being maintained can be found here:
So here we are again.
When you check that README.md is 2 years old and has not been updated. Currently this library is no longer maintained https://github.com/nkolban/esp32-snippets/issues/813
and few more people, including me, is trying to answer questions and help with issues.
Ok, I see. Thanks for that link.
I think it would be important to update this README then: https://github.com/espressif/arduino-esp32/tree/master/libraries/BLE
And thanks for your efforts.
Using ESP-WROOM-32U, running a simple code to simulate
init
anddeinit
of a BLEDevice.Compile settings:
Here are the logs:
The backtrace results in this:
Every single iteration of the init/deinit loop is leaking ~4k, and I could'nt find any other way to fix this. My initial problem is based on this memory leak, I think you could help me with this.
Thanks in advance