Memory Allocation

In this lesson, we will learn about an important subsection of memory management, i.e., memory allocation.

Introduction #

Explicit memory management in C++ has a high complexity but also provides us with great functionality. Sadly, this special domain of C++ is not so well known.

For example, we can directly create objects in static memory, in a reserved area, or even in a memory pool. This functionality is often key in safety-critical applications in the embedded world.

  • C++ enables the dynamic allocation and deallocation of memory.

  • Dynamic memory, or the heap, has to be explicitly requested and released by the programmer.

  • We can use the operators new and new[] to allocate memory and the operators delete and delete[] to deallocate memory.

  • The compiler manages its memory automatically on the stack.

...