memory releasing after task delete

kubera
Posts: 23
Joined: Wed May 20, 2020 10:21 am

memory releasing after task delete

Postby kubera » Thu Aug 20, 2020 5:16 am

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?

ESP_Sprite
Posts: 9739
Joined: Thu Nov 26, 2015 4:08 am

Re: memory releasing after task delete

Postby ESP_Sprite » Thu Aug 20, 2020 8:18 am

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.

kubera
Posts: 23
Joined: Wed May 20, 2020 10:21 am

Re: memory releasing after task delete

Postby kubera » 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

Behemote
Posts: 1
Joined: Thu Sep 03, 2020 7:26 am

Re: memory releasing after task delete

Postby Behemote » Thu Sep 03, 2020 7:27 am

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.

Who is online

Users browsing this forum: Assasinsareus and 104 guests