Heap fragmentation

In an embedded system with limited RAM, heap fragmentation can be a very serious issue. A heap becomes fragmented when items are loaded into the heap and then removed at different points in time. The problem is that if many items that are being removed aren't adjacent to one another, a larger contiguous region of space won't necessarily be available:

In the preceding example, space won't be successfully allocated for item 8. Even though there is sufficient free space, there isn't enough contiguous free space to accommodate the size of item 8. This is especially problematic because it will only occur at runtime, and under certain circumstances that are dependent on the size and timing of when items in the heap are allocated and freed.

Now that we've covered the basics of memory allocation, let's look at some different ways that FreeRTOS primitives can be created to be placed in static or heap memory.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.223.32.230