From 6b6fa902ed7988560cca4aba31bc9d31b32a4cac Mon Sep 17 00:00:00 2001 From: Yuan Hong Hui Date: Wed, 20 Jul 2022 15:06:38 +0800 Subject: [PATCH] ble_mesh:the memory requested by malloc has not benn released --- .../main/ble_mesh_reg_test_perf_client_cmd.c | 21 ++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/examples/bluetooth/esp_ble_mesh/ble_mesh_console/main/ble_mesh_reg_test_perf_client_cmd.c b/examples/bluetooth/esp_ble_mesh/ble_mesh_console/main/ble_mesh_reg_test_perf_client_cmd.c index a2c320e978..ad7202d52e 100644 --- a/examples/bluetooth/esp_ble_mesh/ble_mesh_console/main/ble_mesh_reg_test_perf_client_cmd.c +++ b/examples/bluetooth/esp_ble_mesh/ble_mesh_console/main/ble_mesh_reg_test_perf_client_cmd.c @@ -51,6 +51,7 @@ void ble_mesh_test_performance_client_model_throughput(void *params) esp_ble_mesh_msg_ctx_t ctx; transaction_t *trans = NULL; ble_mesh_test_perf_throughput_data *profile_context = (ble_mesh_test_perf_throughput_data *)params; + esp_err_t result = ESP_OK; ESP_LOGD(TAG, "enter %s\n", __func__); @@ -65,6 +66,7 @@ void ble_mesh_test_performance_client_model_throughput(void *params) data = malloc(profile_context->length); if (data == NULL) { ESP_LOGE(TAG, " %s, %d, malloc fail\n", __func__, __LINE__); + goto cleanup; } for (i = 1; i <= profile_context->test_num; i++) { @@ -73,16 +75,29 @@ void ble_mesh_test_performance_client_model_throughput(void *params) TRANSACTION_INIT(&trans, TRANS_TYPE_MESH_PERF, TRANS_MESH_SEND_MESSAGE, TRANS_MESH_SEND_MESSAGE_EVT, SEND_MESSAGE_TIMEOUT, &start_time, NULL); //tx: data profile_context->length - esp_ble_mesh_client_model_send_msg(profile_context->model, &ctx, profile_context->opcode, - profile_context->length, data, 8000, profile_context->need_ack, profile_context->device_role); + result = esp_ble_mesh_client_model_send_msg(profile_context->model, &ctx, profile_context->opcode, + profile_context->length, data, 8000, + profile_context->need_ack, + profile_context->device_role); ble_mesh_test_performance_client_model_accumulate_statistics(profile_context->length); transaction_run(trans); + + if (result == ESP_OK) { + ESP_LOGI(TAG, "VendorModel:SendPackage,OK"); + } else { + ESP_LOGI(TAG, "VendorModel:SendPackage,Fail"); + } } ESP_LOGI(TAG, "VendorModel:SendPackage,Finish"); + +cleanup: free(params); - vTaskDelete(NULL); + if (data != NULL) { + free(data); + } ESP_LOGD(TAG, "exit %s\n", __func__); + vTaskDelete(NULL); } int ble_mesh_test_performance_client_model(int argc, char **argv)