Quality RTOS & Embedded Software

 Real time embedded FreeRTOS RSS feed 
Real time embedded FreeRTOS mailing list 
Quick Start Supported MCUs PDF Books Trace Tools Ecosystem TCP & FAT Training


Stack memory Defragmentation ?

Posted by Sachin Bhujbal on July 25, 2008
Dear All,
I have one doubt about TaskCreate() & TaskDelete() functions. As per FreeRTOs source code when a task deletes, the memory block used by it is listed in a link list. When we creates a task, it first checks the available free blocks, checks the sizes of them & it uses those free blocks only if any block is having large size than required for that task. In this case there will be memory loss.
Is there any Defragmentation available in FreeRTOs ?
If anybody have any idea, please reply.
Sachin Bhujbal

RE: Stack memory Defragmentation ?

Posted by Dave on July 25, 2008
FreeRTOS uses pvPortMalloc and vPortFree instead of malloc and free. This means you can define whichever memory allocation scheme you want. If you are using heap_2.c and the tasks you create and delete always have the same stack size and there is no other random size memory allocation going on then you should not suffer from fragmentation as the same memory blocks will just get reused.

RE: Stack memory Defragmentation ?

Posted by Sachin Bhujbal on July 25, 2008
Thanks for the Reply,
You have suggested a best thing, for small applications. But it is not possible to keep same stack size for all tasks in big applications because of RAM limitations.

RE: Stack memory Defragmentation ?

Posted by Sachin Bhujbal on August 11, 2008
Dear Dave,
What we will do is we kept two or three fixed stack sizes, high, medium, low.
And we will fit all the tasks in that three stack sizes as per requirement. So this is also benificial. Thanks for giving the clue of solution, Thank You Very Much.

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

Copyright (C) 2004-2010 Richard Barry. Copyright (C) 2010-2016 Real Time Engineers Ltd.
Any and all data, files, source code, html content and documentation included in the FreeRTOSTM distribution or available on this site are the exclusive property of Real Time Engineers Ltd.. See the files license.txt (included in the distribution) and this copyright notice for more information. FreeRTOSTM and FreeRTOS.orgTM are trade marks of Real Time Engineers Ltd.

Latest News:

FreeRTOS V9.0.0 is now available for download.

Free TCP/IP and file system demos for the RTOS

Sponsored Links

⇓ Now With No Code Size Limit! ⇓
⇑ Free Download Without Registering ⇑

FreeRTOS Partners

ARM Connected RTOS partner for all ARM microcontroller cores

Renesas Electronics Gold Alliance RTOS Partner.jpg

Microchip Premier RTOS Partner

RTOS partner of NXP for all NXP ARM microcontrollers

Atmel RTOS partner supporting ARM Cortex-M3 and AVR32 microcontrollers

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

Xilinx Microblaze and Zynq partner

Silicon Labs low power RTOS partner

Altera RTOS partner for Nios II and Cortex-A9 SoC

Freescale Alliance RTOS Member supporting ARM and ColdFire microcontrollers

Infineon ARM Cortex-M microcontrollers

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

Cypress RTOS partner supporting ARM Cortex-M3

Fujitsu RTOS partner supporting ARM Cortex-M3 and FM3

Microsemi (previously Actel) RTOS partner supporting ARM Cortex-M3

Atollic Partner

IAR Partner

Keil ARM Partner

Embedded Artists