ganix22 wrote on Monday, December 01, 2014:
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 heap_1.c to heap_2.c (I also tried heap_3.c and heap_4.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){
LED_1_ON();
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 configCPU_CLOCK_HZ SystemCoreClock
#define configUSE_PREEMPTION 1
#define configUSE_PORT_OPTIMISED_TASK_SELECTION 1
#define configUSE_IDLE_HOOK 1
#define configUSE_TICK_HOOK 1
#define configMAX_PRIORITIES ( 5 )
#define configMINIMAL_STACK_SIZE ( ( unsigned short ) 70 )
#define configTOTAL_HEAP_SIZE ( ( size_t ) ( 14 * 1024 ) )
#define configMAX_TASK_NAME_LEN ( 16 )
#define configUSE_TRACE_FACILITY 1
#define configUSE_16_BIT_TICKS 0
#define configIDLE_SHOULD_YIELD 1
#define configUSE_MUTEXES 1
#define configQUEUE_REGISTRY_SIZE 5
#define configCHECK_FOR_STACK_OVERFLOW 2
#define configUSE_RECURSIVE_MUTEXES 1
#define configUSE_MALLOC_FAILED_HOOK 1
#define configUSE_APPLICATION_TASK_TAG 0
#define configUSE_COUNTING_SEMAPHORES 1
/* Software timer related definitions. */
#define configTIMER_TASK_PRIORITY ( configMAX_PRIORITIES - 1 )
#define configTIMER_QUEUE_LENGTH 10
#define configTIMER_TASK_STACK_DEPTH configMINIMAL_STACK_SIZE
/* Co-routine definitions. */
#define configUSE_CO_ROUTINES 0
#define configMAX_CO_ROUTINE_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