Hi, I have a simple project for STM32L-Discovery board which uses FreeRTOS and I want to delete "Task 2" but it seems that memory is not freed after calling vTaskDelete(), even after replacing memory management scheme from heap1.c to heap2.c (I also tried heap3.c and heap4.c without success). I tried using debugger but there is no sign that vPortFree() is called anyway.
~~~~~~ void Task_1(void* pvParameters){ int i;
unsigned portBASE_TYPE uxPriority;
volatile size_t xHeapSize;
uxPriority = uxTaskPriorityGet(NULL);
while(1){ LED1ON();
xHeapSize = xPortGetFreeHeapSize();
// Create task
xTaskCreate(Task_2, "Task 2", configMINIMAL_STACK_SIZE, NULL, uxPriority+1, &xTask2Handle);
LED_1_OFF();
for(i=0; i<0xAFFFF; ++i);
}
// Delete current task vTaskDelete(NULL); }
void Task_2(void* pvParameters){ // Do something...
// Delete current task vTaskDelete(NULL); } ~~~~~~
Some configs from FreeRTOSConfig.h:
~~~~~~
/* Software timer related definitions. */
/* Co-routine definitions. */
~~~~~~
The memory is not freed until the idle task runs. Does your code let the idle task run?
Of course, you're right! Instead of using for() wait loop there should be vTaskDelay(). Thanks!