Memory Management: Memory Allocation

In this lesson, we will learn about a subsection of memory management - memory allocation.

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 new and new[] to allocate memory and the operators delete and delete[] to deallocate the memory.

  • The compiler manages its memory automatically on the stack.

Smart pointers manages the memory automatically.

Get hands-on with 1400+ tech skills courses.