AnsweredAssumed Answered

FreeRTOS Dynamic Memory Management (STM32F4)

Question asked by #DIV/0! on Aug 19, 2015
Latest reply on Aug 20, 2015 by #DIV/0!

Please see attachment .pdf to see the content I excluded for brevity. 

I have a project with various communication stacks. Messages arrive through one port, and may be processed locally, or routed to another port. Additionally messages may be generated locally and sent to a port. These messages vary significantly in size, with most being less than 64 bytes, but occasionally there will be a packet approaching 1024 Bytes. However, the sizes may be any ware from 1 to 1024 bytes.


I am trying to understand if FreeRTOS supports a fragmentation-safe feature for passing these variable-length packets between threads and between ISR and thread.  For example, is it possible to use malloc() in conjunction with Message Queues (with the producer passing a reference to the allocated memory) without fragmentation concern.


I see in the Heap_4.c source code that it, “combines (coalescences) adjacent memory blocks as they are freed, and in so doing limits memory fragmentation.” However, this still concerns me because my product may not be reset for months of run-time. It seems very difficult to test if the coalescence scheme is effective enough.


I was considering the scheme described here …




… which I’ll paste below:


  [See attachment For this content]

I’ve read the “Memory Management” documentation of FreeRTOS …


   FreeRTOS Memory Management


… as well as skimmed the source code, but I am not confident that the heap implementation will meet my requirements.


I will paste “Memory Management” documentation below as well.


  [See attachment For this content]




1)      Am I correct in my assessment that that the FreeRTOS heap implementation is not fragmentation-safe?


… and if yes …


2)      Is there a ‘typical/canned solution’ for this issue that can be implemented ‘on top’ of FreeRTOS/CMSIS? E.g. the Memory Pool scheme.








See also: