Fundamentals of C++ Game Development: Dynamic Memory Allocation with new and delete

Fundamentals of C++ Game Development: Dynamic Memory Allocation with new and delete

Before discussing dynamic memory allocation, let’s first look at the two basic types of memory allocation in C++: Static memory allocation is used for static and global variables. The memory for these variables is allocated all at once when the program runs and lasts for the entire lifecycle of the program. Automatic memory allocation is … Read more

Understanding the Principles of C++ Smart Pointers

Understanding the Principles of C++ Smart Pointers

C++ smart pointers are tools that manage dynamically allocated memory through the RAII (Resource Acquisition Is Initialization) technique, which helps avoid common memory leak issues associated with manual memory management. Below, we detail its two core mechanisms: reference counting and custom deleters. 1. Reference Counting Principle Reference counting is the fundamental mechanism for the automatic … Read more