Page 1 of 1

memory releasing after task delete

Posted: Thu Aug 20, 2020 5:16 am
by kubera
Hi,
I have wifi and ble in separate tasks. implemented blufi along with it for provisioning.
while switching from one task to another I call vTaskDelete(handler). To delete that task. But unfortunately i doubut memory is not released by that call. How can we free the memory?

Re: memory releasing after task delete

Posted: Thu Aug 20, 2020 8:18 am
by ESP_Sprite
The memory that is used by the stack and TCB of your task will get automatically released. If your task (or any function that it calls) does heap allocation (e.g. malloc, calloc, new, ...), that memory is not released; you need to release that yourself somehow. One option would be some sort of signal (e.g. a semaphore) that is sent to the task so it can clean up and delete itself.

Re: memory releasing after task delete

Posted: Sun Aug 23, 2020 4:01 am
by kubera
Thanks for the reply,
ESP_Sprite

"abort() was called at PC 0x40082f56 on core 0
0x40082f56: lock_acquire generic at C:/Users/Desktop/esp-idf/components newlib/locks.c:143
"

This is the error I am getting after the following flow. The program starts with wifi then shifts to BLE upon getting notifications:- deleting wifi task and de-initializing wifi. Then Shifts to BluFi upon user request then delete the BLE task and de-initializing the BLE task switch to BluFi. Upon completing the task the firmware crashes as above. Can you tell me what was causing this issue

Re: memory releasing after task delete

Posted: Thu Sep 03, 2020 7:27 am
by Behemote
kubera wrote:
Sun Aug 23, 2020 4:01 am
Thanks for the reply,
ESP_Sprite

"abort() was called at PC 0x40082f56 on core 0
0x40082f56: lock_acquire generic at C:/Users/Desktop/esp-idf/components newlib/locks.c:143
"

This is the error I am getting after the following flow. The program starts with wifi then shifts to BLE upon getting notifications:- deleting wifi task and de-initializing wifi. Then Shifts to BluFi upon user request then delete the BLE task and de-initializing the BLE task switch to BluFi. Upon completing the task the firmware crashes as above. Can you tell me what was causing this issue
If your task (or any function that it calls) does heap allocation (e.g. malloc, calloc, new, ...), that memory is not released; you need to release that yourself somehow.