Quality RTOS & Embedded Software

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




Loading

Stack Memory Defragmentation - heap_2.c

Posted by fkln on January 28, 2009
Are there any workarounds concering the problem of the Memory Defragmentation of the heap ?

My idea is, during vPortFree() look at the following block and the previous block in the list of free blocks.
If any or both blocks are free, it should be possible to combine the free blocks to one common free block.

With this solution, the defragmentation should be avoided ?

Any comments ?

Klaus

RE: Stack Memory Defragmentation - heap_2.c

Posted by Dave on January 28, 2009
It is common for heap managers to combine adjacent free blocks. This reduces but does not remove fragmentation problems. It generally also makes the functions slower and less deterministic.


RE: Stack Memory Defragmentation - heap_2.c

Posted by fkln on January 28, 2009
Are there any add-ons for FreeRTOS for such a heap manager ?

Klaus

RE: Stack Memory Defragmentation - heap_2.c

Posted by Raphael Derosso Pereira on January 28, 2009
It mainly depend on your development environment. For example, if you use GCC and newlib, you could use its malloc() and free() implementation, that already take care of that.

RE: Stack Memory Defragmentation - heap_2.c

Posted by incrediball on January 28, 2009
If the defragmenting would be done by something optional in the idle task, the speed of the operation shouldn't be a concern, unless a significant amount of time is spent inside critical sections.

To the person who suggested malloc/free: how useful is that really for embedded systems? malloc just seems a bit too general purpose for me with no way of configuring it, i.e. total heap size, minimum/maximum block size, where is any housekeeping done, what are worst and best case conditions, etc. I actually wound up writing my own heap manager because I wanted something handle based that would allow blocks to be relocated and reference counted.

RE: Stack Memory Defragmentation - heap_2.c

Posted by fkln on January 29, 2009
Thanks for the replies. I think, the solution with the defragmentation in the idle task is the best solution. Is a source code for this solution available ?


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




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

Latest News

FreeRTOS kernel V10 is available for immediate download. Now MIT licensed.


FreeRTOS Partners

ARM Connected RTOS partner for all ARM microcontroller cores

IAR Partner

Microchip Premier RTOS Partner

RTOS partner of NXP for all NXP ARM microcontrollers

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