vPortFree() is not called

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: ~~~~~~

define configCPUCLOCKHZ SystemCoreClock

define configUSE_PREEMPTION 1

define configUSEPORTOPTIMISEDTASKSELECTION 1

define configUSEIDLEHOOK 1

define configUSETICKHOOK 1

define configMAX_PRIORITIES ( 5 )

define configMINIMALSTACKSIZE ( ( unsigned short ) 70 )

define configTOTALHEAPSIZE ( ( size_t ) ( 14 * 1024 ) )

define configMAXTASKNAME_LEN ( 16 )

define configUSETRACEFACILITY 1

define configUSE16BIT_TICKS 0

define configIDLESHOULDYIELD 1

define configUSE_MUTEXES 1

define configQUEUEREGISTRYSIZE 5

define configCHECKFORSTACK_OVERFLOW 2

define configUSERECURSIVEMUTEXES 1

define configUSEMALLOCFAILED_HOOK 1

define configUSEAPPLICATIONTASK_TAG 0

define configUSECOUNTINGSEMAPHORES 1

/* Software timer related definitions. */

define configTIMERTASKPRIORITY ( configMAX_PRIORITIES – 1 )

define configTIMERQUEUELENGTH 10

define configTIMERTASKSTACKDEPTH configMINIMALSTACK_SIZE

/* Co-routine definitions. */

define configUSECOROUTINES 0

define configMAXCOROUTINE_PRIORITIES ( 2 )

define INCLUDE_vTaskPrioritySet 1

define INCLUDE_uxTaskPriorityGet 1

define INCLUDE_vTaskDelete 1

define INCLUDE_vTaskCleanUpResources 0

define INCLUDE_vTaskSuspend 1

define INCLUDE_vTaskDelayUntil 1

define INCLUDE_vTaskDelay 1

~~~~~~

vPortFree() is not called

The memory is not freed until the idle task runs. Does your code let the idle task run?

vPortFree() is not called

Of course, you’re right! Instead of using for() wait loop there should be vTaskDelay(). Thanks!