In my application, I am periodically enabling / disabling ble (bluedroid). I have noticed that with each init / denit cycle, almost 700 bytes of heap memory is leaking. I did find serveral posts regarding this issue on the forum and on the net, but no conclusive solution.
Code: Select all
I (1257) TEST_MEM_LEAK: BEFORE : 216208
D (1257) intr_alloc: Connected src -5 to int 29 (cpu 0)
D (1267) efuse: In EFUSE_BLK0__DATA2_REG is used 8 bits starting with 8 bit
D (1277) efuse: In EFUSE_BLK0__DATA2_REG is used 8 bits starting with 0 bit
D (1277) efuse: In EFUSE_BLK0__DATA1_REG is used 8 bits starting with 24 bit
D (1287) efuse: In EFUSE_BLK0__DATA1_REG is used 8 bits starting with 16 bit
D (1297) efuse: In EFUSE_BLK0__DATA1_REG is used 8 bits starting with 8 bit
D (1297) efuse: In EFUSE_BLK0__DATA1_REG is used 8 bits starting with 0 bit
D (1307) efuse: In EFUSE_BLK0__DATA2_REG is used 8 bits starting with 16 bit
D (1317) efuse: In EFUSE_BLK0__DATA2_REG is used 8 bits starting with 8 bit
D (1327) efuse: In EFUSE_BLK0__DATA2_REG is used 8 bits starting with 0 bit
D (1327) efuse: In EFUSE_BLK0__DATA1_REG is used 8 bits starting with 24 bit
D (1337) efuse: In EFUSE_BLK0__DATA1_REG is used 8 bits starting with 16 bit
D (1347) efuse: In EFUSE_BLK0__DATA1_REG is used 8 bits starting with 8 bit
D (1347) efuse: In EFUSE_BLK0__DATA1_REG is used 8 bits starting with 0 bit
D (1357) efuse: In EFUSE_BLK0__DATA2_REG is used 8 bits starting with 16 bit
D (1377) efuse: In EFUSE_BLK0__DATA2_REG is used 8 bits starting with 8 bit
D (1377) efuse: In EFUSE_BLK0__DATA2_REG is used 8 bits starting with 0 bit
D (1377) efuse: In EFUSE_BLK0__DATA1_REG is used 8 bits starting with 24 bit
D (1387) efuse: In EFUSE_BLK0__DATA1_REG is used 8 bits starting with 16 bit
D (1397) efuse: In EFUSE_BLK0__DATA1_REG is used 8 bits starting with 8 bit
D (1397) efuse: In EFUSE_BLK0__DATA1_REG is used 8 bits starting with 0 bit
D (1407) efuse: In EFUSE_BLK0__DATA2_REG is used 8 bits starting with 16 bit
I (2257) TEST_MEM_LEAK: AFTER START : 190460
I (9257) TEST_MEM_LEAK: AFTER STOP : 228924
I (9257) TEST_MEM_LEAK: -----------------------------------------
I (9257) TEST_MEM_LEAK: BEFORE : 228924
I (10257) TEST_MEM_LEAK: AFTER START : 189696
I (17257) TEST_MEM_LEAK: AFTER STOP : 228160
I (17257) TEST_MEM_LEAK: -----------------------------------------
I (17257) TEST_MEM_LEAK: BEFORE : 228160
I (18257) TEST_MEM_LEAK: AFTER START : 188932
I (25257) TEST_MEM_LEAK: AFTER STOP : 227396
I (25257) TEST_MEM_LEAK: -----------------------------------------
I (25257) TEST_MEM_LEAK: BEFORE : 227396
I (26257) TEST_MEM_LEAK: AFTER START : 188168
I (33257) TEST_MEM_LEAK: AFTER STOP : 226632
I (33257) TEST_MEM_LEAK: -----------------------------------------
I (33257) TEST_MEM_LEAK: BEFORE : 226632
I (34257) TEST_MEM_LEAK: AFTER START : 187404
I (41257) TEST_MEM_LEAK: AFTER STOP : 225868
I (41257) TEST_MEM_LEAK: -----------------------------------------
I (41257) TEST_MEM_LEAK: BEFORE : 225868
I (42257) TEST_MEM_LEAK: AFTER START : 186640
I (49257) TEST_MEM_LEAK: AFTER STOP : 225104
I (49257) TEST_MEM_LEAK: -----------------------------------------
I (49257) TEST_MEM_LEAK: BEFORE : 225104
I (50257) TEST_MEM_LEAK: AFTER START : 185876
I (57257) TEST_MEM_LEAK: AFTER STOP : 224340
I (57257) TEST_MEM_LEAK: -----------------------------------------
I (57257) TEST_MEM_LEAK: BEFORE : 224340
I (58257) TEST_MEM_LEAK: AFTER START : 185112
I (65257) TEST_MEM_LEAK: AFTER STOP : 223576
I (65257) TEST_MEM_LEAK: -----------------------------------------
I (65257) TEST_MEM_LEAK: BEFORE : 223576
I (66257) TEST_MEM_LEAK: AFTER START : 184348
I (73257) TEST_MEM_LEAK: AFTER STOP : 222812
I (73257) TEST_MEM_LEAK: -----------------------------------------
I (73257) TEST_MEM_LEAK: BEFORE : 222812
I (74257) TEST_MEM_LEAK: AFTER START : 183584
I (81257) TEST_MEM_LEAK: AFTER STOP : 222048
I (81257) TEST_MEM_LEAK: -----------------------------------------
I (81257) TEST_MEM_LEAK: BEFORE : 222048
I (82257) TEST_MEM_LEAK: AFTER START : 182820
I (89257) TEST_MEM_LEAK: AFTER STOP : 221284
I (89257) TEST_MEM_LEAK: -----------------------------------------
I (89257) TEST_MEM_LEAK: BEFORE : 221284
I (90257) TEST_MEM_LEAK: AFTER START : 182056
I (97257) TEST_MEM_LEAK: AFTER STOP : 220520
I (97257) TEST_MEM_LEAK: -----------------------------------------
I (97257) TEST_MEM_LEAK: BEFORE : 220520
I (98257) TEST_MEM_LEAK: AFTER START : 181292
I (105257) TEST_MEM_LEAK: AFTER STOP : 219756
I (105257) TEST_MEM_LEAK: -----------------------------------------
I (105257) TEST_MEM_LEAK: BEFORE : 219756
I (106257) TEST_MEM_LEAK: AFTER START : 180528
I (113257) TEST_MEM_LEAK: AFTER STOP : 218992
I (113257) TEST_MEM_LEAK: -----------------------------------------
I (113257) TEST_MEM_LEAK: BEFORE : 218992
I (114257) TEST_MEM_LEAK: AFTER START : 179764
I (121257) TEST_MEM_LEAK: AFTER STOP : 218228
I (121257) TEST_MEM_LEAK: -----------------------------------------
I (121257) TEST_MEM_LEAK: BEFORE : 218228
I (122257) TEST_MEM_LEAK: AFTER START : 179000
I (129257) TEST_MEM_LEAK: AFTER STOP : 217464
I (129257) TEST_MEM_LEAK: -----------------------------------------
I (129257) TEST_MEM_LEAK: BEFORE : 217464
I (130257) TEST_MEM_LEAK: AFTER START : 178236
I (137257) TEST_MEM_LEAK: AFTER STOP : 216700
I (137257) TEST_MEM_LEAK: -----------------------------------------
I (137257) TEST_MEM_LEAK: BEFORE : 216700
I (138257) TEST_MEM_LEAK: AFTER START : 177472
I (145257) TEST_MEM_LEAK: AFTER STOP : 215936
I (145257) TEST_MEM_LEAK: -----------------------------------------
I (145257) TEST_MEM_LEAK: BEFORE : 215936
I (146257) TEST_MEM_LEAK: AFTER START : 176708
I (153257) TEST_MEM_LEAK: AFTER STOP : 215172
I (153257) TEST_MEM_LEAK: -----------------------------------------
I (153257) TEST_MEM_LEAK: BEFORE : 215172
I (154257) TEST_MEM_LEAK: AFTER START : 175944
I (161257) TEST_MEM_LEAK: AFTER STOP : 214408
I (161257) TEST_MEM_LEAK: -----------------------------------------
I (161257) TEST_MEM_LEAK: BEFORE : 214408
I (162257) TEST_MEM_LEAK: AFTER START : 175180
I (169257) TEST_MEM_LEAK: AFTER STOP : 213644
I (169257) TEST_MEM_LEAK: -----------------------------------------
I (169257) TEST_MEM_LEAK: BEFORE : 213644
I (170257) TEST_MEM_LEAK: AFTER START : 174416
I (177257) TEST_MEM_LEAK: AFTER STOP : 212880
I (177257) TEST_MEM_LEAK: -----------------------------------------
I (177257) TEST_MEM_LEAK: BEFORE : 212880
I (178257) TEST_MEM_LEAK: AFTER START : 173652
I (185257) TEST_MEM_LEAK: AFTER STOP : 212116
I (185257) TEST_MEM_LEAK: -----------------------------------------
I (185257) TEST_MEM_LEAK: BEFORE : 212116
I (186257) TEST_MEM_LEAK: AFTER START : 172888
I (193257) TEST_MEM_LEAK: AFTER STOP : 211352
I (193257) TEST_MEM_LEAK: -----------------------------------------
I (193257) TEST_MEM_LEAK: BEFORE : 211352
I (194257) TEST_MEM_LEAK: AFTER START : 172124
I (201257) TEST_MEM_LEAK: AFTER STOP : 210588
I (201257) TEST_MEM_LEAK: -----------------------------------------
I (201257) TEST_MEM_LEAK: BEFORE : 210588
I (202257) TEST_MEM_LEAK: AFTER START : 171360
I (209257) TEST_MEM_LEAK: AFTER STOP : 209824
I (209257) TEST_MEM_LEAK: -----------------------------------------
I (209257) TEST_MEM_LEAK: BEFORE : 209824
I (210257) TEST_MEM_LEAK: AFTER START : 170596
Code: Select all
static void s_start(void)
{
//Start Ble Driver Stack
esp_err_t err;
esp_bt_controller_config_t bt_cfg = BT_CONTROLLER_INIT_CONFIG_DEFAULT();
//Free Up Ble Classic Memory
err = esp_bt_controller_mem_release(ESP_BT_MODE_CLASSIC_BT);
if((err = esp_bt_controller_init(&bt_cfg)) != ESP_OK)
{
goto start_fail;
}
if((err = esp_bt_controller_enable(ESP_BT_MODE_BLE)) != ESP_OK)
{
goto start_fail;
}
if((err = esp_bluedroid_init()) != ESP_OK)
{
goto start_fail;
}
if((err = esp_bluedroid_enable()) != ESP_OK)
{
goto start_fail;
}
//Register Ble Gap Cb Function
if((err = esp_ble_gap_register_callback(s_gap_cb)) != ESP_OK)
{
goto start_fail;
}
//Register Ble Gattc Cb Function
if((err = esp_ble_gattc_register_callback(s_gattc_cb)) != ESP_OK)
{
goto start_fail;
}
//Register Gattc Application Profile
if((err = esp_ble_gattc_app_register(DRIVER_BLE_APPLICATION_PROFILE_A_ID)) != ESP_OK)
{
goto start_fail;
}
//Gatt Set Mtu Size
if((err = esp_ble_gatt_set_local_mtu(BLE_MTU_SIZE_MAX)) != ESP_OK)
{
goto start_fail;
}
s_set_ready_status_bit(DRIVER_BLE_EB_STATUS_READY);
ESP_LOGD(DRIVER_BLE_TAG, "Start OK");
return;
start_fail:
s_set_ready_status_bit(DRIVER_BLE_EB_STATUS_NOTREADY);
ESP_LOGD(DRIVER_BLE_TAG, "Start FAIL. %s", esp_err_to_name(err));
}
Code: Select all
static void s_stop(void)
{
//Stop Ble Driver Stack
esp_err_t err;
if((err = esp_bluedroid_disable()) != ESP_OK)
{
goto stop_fail;
}
if((err = esp_bt_controller_disable()) != ESP_OK)
{
goto stop_fail;
}
if((err = esp_bluedroid_deinit()) != ESP_OK)
{
goto stop_fail;
}
if((err = esp_bt_controller_deinit()) != ESP_OK)
{
goto stop_fail;
}
s_set_ready_status_bit(DRIVER_BLE_EB_STATUS_NOTREADY);
ESP_LOGD(DRIVER_BLE_TAG, "Stop OK");
return;
stop_fail:
s_set_ready_status_bit(DRIVER_BLE_EB_STATUS_READY);
ESP_LOGD(DRIVER_BLE_TAG, "Stop FAIL. %s", esp_err_to_name(err));
}