Quality RTOS & Embedded Software

 Real time embedded FreeRTOS RSS feed 
Quick Start Supported MCUs PDF Books Trace Tools Ecosystem


Loading

vPortFree() is not called

Posted by ganix22 on December 1, 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 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

Posted by edwards3 on December 1, 2014

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


vPortFree() is not called

Posted by ganix22 on December 1, 2014

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


[ Back to the top ]    [ About FreeRTOS ]    [ Privacy ]    [ Sitemap ]    [ ]


Copyright (C) Amazon Web Services, Inc. or its affiliates. All rights reserved.

Latest News

NXP tweet showing LPC5500 (ARMv8-M Cortex-M33) running FreeRTOS.

Meet Richard Barry and learn about running FreeRTOS on RISC-V at FOSDEM 2019

Version 10.1.1 of the FreeRTOS kernel is available for immediate download. MIT licensed.

View a recording of the "OTA Update Security and Reliability" webinar, presented by TI and AWS.


Careers

FreeRTOS and other embedded software careers at AWS.



FreeRTOS Partners

ARM Connected RTOS partner for all ARM microcontroller cores

Espressif ESP32

IAR Partner

Microchip Premier RTOS Partner

RTOS partner of NXP for all NXP ARM microcontrollers

Renesas

STMicro RTOS partner supporting ARM7, ARM Cortex-M3, ARM Cortex-M4 and ARM Cortex-M0

Texas Instruments MCU Developer Network RTOS partner for ARM and MSP430 microcontrollers

OpenRTOS and SafeRTOS

Xilinx Microblaze and Zynq partner