【已解决】调用esp_mesh_lite_try_sending_msg后free heap越来越少的问题
Posted: Wed Feb 21, 2024 6:57 am
最近基于esp-mesh-lit>examples>no_router的demo改写了一个从串口接收数据,然后广播到组网设备的功能。
验证功能过程中发现,每次调用esp_mesh_lite_try_sending_msg,可用的free heap就越来越少,多次调用后,系统因为heap不够奔溃了。
起初是以为cJSON的item没有释放掉,但查到后面发现只要注释掉esp_mesh_lite_try_sending_msg这个api,heap就正常,大伙有碰到过类似的问题么?
使用的硬件是esp32-c3-mini-1开发板,
各依赖组件版本如下:
[1/5] espressif/cmake_utilities (0.5.3)
[2/5] espressif/esp_modem (1.1.0)
[3/5] espressif/iot_bridge (0.11.0)
[4/5] espressif/mesh_lite (0.10.0)
[5/5] idf (5.1.2)
下面是部分log,
I (561116) no_router: sys info, channel: 11, layer: 2, self mac: 68:67:25:e6:a9:38, parent bssid: 10:91:a8:21:5c:e5, parent rssi: -14, free heap: 167884
I (571116) no_router: sys info, channel: 11, layer: 2, self mac: 68:67:25:e6:a9:38, parent bssid: 10:91:a8:21:5c:e5, parent rssi: -15, free heap: 167884
I (581116) no_router: sys info, channel: 11, layer: 2, self mac: 68:67:25:e6:a9:38, parent bssid: 10:91:a8:21:5c:e5, parent rssi: -15, free heap: 167884
I (591116) no_router: sys info, channel: 11, layer: 2, self mac: 68:67:25:e6:a9:38, parent bssid: 10:91:a8:21:5c:e5, parent rssi: -15, free heap: 167884
I (601116) no_router: sys info, channel: 11, layer: 2, self mac: 68:67:25:e6:a9:38, parent bssid: 10:91:a8:21:5c:e5, parent rssi: -14, free heap: 167752
I (604216) uart_port: uart1 recv, count: 0, len: 4
I (605076) uart_port: uart1 recv, count: 1, len: 4
I (605596) uart_port: uart1 recv, count: 2, len: 4
I (605856) uart_port: uart1 recv, count: 3, len: 4
I (611116) no_router: sys info, channel: 11, layer: 2, self mac: 68:67:25:e6:a9:38, parent bssid: 10:91:a8:21:5c:e5, parent rssi: -15, free heap: 167380
I (613746) uart_port: uart1 recv, count: 4, len: 4
I (613926) uart_port: uart1 recv, count: 5, len: 4
I (614136) uart_port: uart1 recv, count: 6, len: 4
I (614346) uart_port: uart1 recv, count: 7, len: 4
I (621116) no_router: sys info, channel: 11, layer: 2, self mac: 68:67:25:e6:a9:38, parent bssid: 10:91:a8:21:5c:e5, parent rssi: -15, free heap: 167036
I (623196) uart_port: uart1 recv, count: 8, len: 4
I (623416) uart_port: uart1 recv, count: 9, len: 4
I (623586) uart_port: uart1 recv, count: 10, len: 4
I (623816) uart_port: uart1 recv, count: 11, len: 4
I (631116) no_router: sys info, channel: 11, layer: 2, self mac: 68:67:25:e6:a9:38, parent bssid: 10:91:a8:21:5c:e5, parent rssi: -14, free heap: 166688
I (631856) uart_port: uart1 recv, count: 12, len: 4
I (632036) uart_port: uart1 recv, count: 13, len: 4
I (632226) uart_port: uart1 recv, count: 14, len: 4
I (632436) uart_port: uart1 recv, count: 15, len: 4
I (641116) no_router: sys info, channel: 11, layer: 2, self mac: 68:67:25:e6:a9:38, parent bssid: 10:91:a8:21:5c:e5, parent rssi: -15, free heap: 166348
I (642306) uart_port: uart1 recv, count: 16, len: 4
I (642476) uart_port: uart1 recv, count: 17, len: 4
I (642666) uart_port: uart1 recv, count: 18, len: 4
I (642896) uart_port: uart1 recv, count: 19, len: 4
I (651116) no_router: sys info, channel: 11, layer: 2, self mac: 68:67:25:e6:a9:38, parent bssid: 10:91:a8:21:5c:e5, parent rssi: -15, free heap: 166004
I (661116) no_router: sys info, channel: 11, layer: 2, self mac: 68:67:25:e6:a9:38, parent bssid: 10:91:a8:21:5c:e5, parent rssi: -15, free heap: 166004
I (671116) no_router: sys info, channel: 11, layer: 2, self mac: 68:67:25:e6:a9:38, parent bssid: 10:91:a8:21:5c:e5, parent rssi: -15, free heap: 166004
附上实现功能的c文件:
验证功能过程中发现,每次调用esp_mesh_lite_try_sending_msg,可用的free heap就越来越少,多次调用后,系统因为heap不够奔溃了。
起初是以为cJSON的item没有释放掉,但查到后面发现只要注释掉esp_mesh_lite_try_sending_msg这个api,heap就正常,大伙有碰到过类似的问题么?
使用的硬件是esp32-c3-mini-1开发板,
各依赖组件版本如下:
[1/5] espressif/cmake_utilities (0.5.3)
[2/5] espressif/esp_modem (1.1.0)
[3/5] espressif/iot_bridge (0.11.0)
[4/5] espressif/mesh_lite (0.10.0)
[5/5] idf (5.1.2)
下面是部分log,
I (561116) no_router: sys info, channel: 11, layer: 2, self mac: 68:67:25:e6:a9:38, parent bssid: 10:91:a8:21:5c:e5, parent rssi: -14, free heap: 167884
I (571116) no_router: sys info, channel: 11, layer: 2, self mac: 68:67:25:e6:a9:38, parent bssid: 10:91:a8:21:5c:e5, parent rssi: -15, free heap: 167884
I (581116) no_router: sys info, channel: 11, layer: 2, self mac: 68:67:25:e6:a9:38, parent bssid: 10:91:a8:21:5c:e5, parent rssi: -15, free heap: 167884
I (591116) no_router: sys info, channel: 11, layer: 2, self mac: 68:67:25:e6:a9:38, parent bssid: 10:91:a8:21:5c:e5, parent rssi: -15, free heap: 167884
I (601116) no_router: sys info, channel: 11, layer: 2, self mac: 68:67:25:e6:a9:38, parent bssid: 10:91:a8:21:5c:e5, parent rssi: -14, free heap: 167752
I (604216) uart_port: uart1 recv, count: 0, len: 4
I (605076) uart_port: uart1 recv, count: 1, len: 4
I (605596) uart_port: uart1 recv, count: 2, len: 4
I (605856) uart_port: uart1 recv, count: 3, len: 4
I (611116) no_router: sys info, channel: 11, layer: 2, self mac: 68:67:25:e6:a9:38, parent bssid: 10:91:a8:21:5c:e5, parent rssi: -15, free heap: 167380
I (613746) uart_port: uart1 recv, count: 4, len: 4
I (613926) uart_port: uart1 recv, count: 5, len: 4
I (614136) uart_port: uart1 recv, count: 6, len: 4
I (614346) uart_port: uart1 recv, count: 7, len: 4
I (621116) no_router: sys info, channel: 11, layer: 2, self mac: 68:67:25:e6:a9:38, parent bssid: 10:91:a8:21:5c:e5, parent rssi: -15, free heap: 167036
I (623196) uart_port: uart1 recv, count: 8, len: 4
I (623416) uart_port: uart1 recv, count: 9, len: 4
I (623586) uart_port: uart1 recv, count: 10, len: 4
I (623816) uart_port: uart1 recv, count: 11, len: 4
I (631116) no_router: sys info, channel: 11, layer: 2, self mac: 68:67:25:e6:a9:38, parent bssid: 10:91:a8:21:5c:e5, parent rssi: -14, free heap: 166688
I (631856) uart_port: uart1 recv, count: 12, len: 4
I (632036) uart_port: uart1 recv, count: 13, len: 4
I (632226) uart_port: uart1 recv, count: 14, len: 4
I (632436) uart_port: uart1 recv, count: 15, len: 4
I (641116) no_router: sys info, channel: 11, layer: 2, self mac: 68:67:25:e6:a9:38, parent bssid: 10:91:a8:21:5c:e5, parent rssi: -15, free heap: 166348
I (642306) uart_port: uart1 recv, count: 16, len: 4
I (642476) uart_port: uart1 recv, count: 17, len: 4
I (642666) uart_port: uart1 recv, count: 18, len: 4
I (642896) uart_port: uart1 recv, count: 19, len: 4
I (651116) no_router: sys info, channel: 11, layer: 2, self mac: 68:67:25:e6:a9:38, parent bssid: 10:91:a8:21:5c:e5, parent rssi: -15, free heap: 166004
I (661116) no_router: sys info, channel: 11, layer: 2, self mac: 68:67:25:e6:a9:38, parent bssid: 10:91:a8:21:5c:e5, parent rssi: -15, free heap: 166004
I (671116) no_router: sys info, channel: 11, layer: 2, self mac: 68:67:25:e6:a9:38, parent bssid: 10:91:a8:21:5c:e5, parent rssi: -15, free heap: 166004
附上实现功能的c文件: