Memory management

C++ allows a pretty fine-grained memory control by allowing us to choose explicitly between stack and heap memory, and it goes even further, by providing customization points for the used memory allocation strategies. We can do it by doing the following:

  • Replacing the global memory allocator for the program
  • Using own allocation strategies for a single class
  • Using custom std::Allocator for Standard Template Library (STL) container classes