Memory Management

Memory efficiency is one of the major requirements for embedded applications. Since target embedded platforms often have limited performance and memory capabilities, developers need to know how to use available memory in the most efficient way.

Surprisingly, the most efficient way does not necessarily mean that the least amount of memory is used. Since embedded systems are specialized, developers know in advance which applications or components will be executed on the system. Saving memory in one application does not result in any gain unless another application running in the same system can use the extra memory. That is why the most important characteristic of memory management in embedded systems is determinism, or predictability. It is much more important to know that an application can use two megabytes of memory under any load than knowing an application can use one megabyte of memory most of the time, but can occasionally require three megabytes.

Similarly, predictability also applies to memory allocation and deallocation time. In many situations, embedded applications favor spending more memory to achieve deterministic timing.

In this chapter, we will learn several of memory management techniques  that are widely used in embedded applications. The recipes covered in this chapter are as follows:

These recipes will help you understand memory management best practices and can be used as building blocks when working with memory allocation in your applications.