Stack memory Defragmentation ?

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. Thanks, Sachin Bhujbal

Stack memory Defragmentation ?

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.

Stack memory Defragmentation ?

Dave,    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.

Stack memory Defragmentation ?

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.