SuperHouse / esp-open-rtos

Open source FreeRTOS-based ESP8266 software framework
BSD 3-Clause "New" or "Revised" License
1.52k stars 491 forks source link

vTaskDelete can't free memery #606

Closed donny681 closed 6 years ago

donny681 commented 6 years ago

I found that it delete the task successfully.But it can't free memery.It failed to xTaskCreate the same task after delete the task. I think that it may be something wrong with the system.

ourairquality commented 6 years ago

Could you provide an example to reproduce the problem?

joostn commented 6 years ago

According to https://www.freertos.org/a00126.html :

NOTE: The idle task is responsible for freeing the RTOS kernel allocated memory from tasks that have been deleted. It is therefore important that the idle task is not starved of microcontroller processing time if your application makes any calls to vTaskDelete (). Memory allocated by the task code is not automatically freed, and should be freed before the task is deleted.

So it appears the memory is not released immediately after calling vTaskDelete. Could that be the issue?

ourairquality commented 6 years ago

The idle task does run, and the memory does appear to be freed. There might be some delay, or the idle task might be starved and not running in some particular app, or the heap might become fragmented, but these do not appear to be a issues that needs to be addressed here. A simple test looping creating a task that deletes itself does not leak memory here.