I’m working on a project on an STM32F4 with FreeRtos 8.2.0. My program malloc and Free a lot of little structures (i know this possibly leads to fragmentation but i don’t really have the choice) and i use heap 4.
I use xPortGetFreeHeapSize() to monitor my memory allocated in my heap. On the side i have done a trace tool which trace all malloc and free actions (i’m aware that the length of the objects doesn’t take in account the extra data added in freertos malloc).
TYPE SIZE MALLOC TSD 20 MALLOC OFL 8 MALLOC PAT 8 FREE OFL 8 MALLOC CUR 16 MALLOC OFL 8 MALLOC LOE 8 FREE OFL 8 MALLOC OFL 8 FREE TSD 20 FREE PAT 8 FREE LOE 8 FREE OFL 8 MALLOC OFL 8 FREE CUR 16 FREE OFL 8
Sum_Malloc - Sum_Free = 0 but when i monitor with xPortGetFreeHeapSize the first time i perform this action, 8 byte are still present and the second time it returns to 0 and so forth and so on.
When i perform a lot of this kind of actions it fills all the memory slowly. This is what really bother me…
Do you think it is an alignement issue ? I’m not thinking about fragmentation because if i understand well xPortGetFreeHeapSize can’t monitor it.
more generally do you think that i should use the heap 5 to use it’s ability to span data or should i allocate areas in ram in order to store all the same size structures in the same areas ?
Do you have other ideas ?
One more thing i can’t know in advance how much of each structures will be created that’s why everything is malloced dynamicaly.
Thanks in advance for your help !