Memory Management
5-8
Figure 5-1. Allocating Memory Segments of Different Sizes
Note:
To minimize memory fragmentation, allocate smaller, equal-sized blocks of
memory from one memory segment and larger equal-sized blocks of
memory from a second segment.
5.1.7 MEM Example
Example 5-7 and Example 5-8 use the functions MEM_stat, MEM_alloc, and
MEM_free to highlight several issues involved with memory allocation. Figure
5-2 shows the trace results from Example 5-7 or Example 5-8.
In Example 5-7 and Example 5-8, memory is allocated from IDATA and
IDRAM memory using MEM_alloc, and later freed using MEM_free.
printmem is used to print the memory status to the trace buffer. The final
values (for example, “after freeing...”) should match the initial values.
Segment #
0
1
Target Memory
Allocate small
blocks from one
segment for
messages
Allocate large
blocks from
another segment
for streams