Memory Management: Memory Allocation
Understand how to manage dynamic memory effectively in embedded systems using Modern C++. Explore operators like new and new[], placement new for pre-reserved memory, and ways to handle allocation failures. Gain skills essential for safety-critical applications with limited resources.
We'll cover the following...
Introduction
Explicit memory management in C++ is highly complex, but it also provides us with great functionality. Unfortunately, this special domain is not as common in C++. For example, you can directly create objects in static memory, in a reserved area, or even in a memory pool. This functionality is often key in the safety-critical applications of the embedded world.
-
C++ enables the dynamic allocation and deallocation of memory.
-
Dynamic memory (heap) must be explicitly requested and released by the programmer.
-
You can use the operators
newandnew[]to allocate memory and the operatorsdeleteanddelete[]to deallocate the memory. -
The compiler manages its memory automatically on the stack.
...