0

What is dynamic memory

What is dynamic memory in c++

7th Sep 2025, 12:37 PM
Sidheshwar Tiwari
3 Antwoorden
+ 1
As you know, automatic variables, also called scoped variables, are stored on the stack. These have a fixed size (static) and will be gone once the scope is terminated. On the other hand, there's the heap where you can create dynamic variables giving you more flexibility and control. Basically instead of giving the size fixed at compile time, the heap gives dynamic size at runtime. To use that dynamic memory, you need a pointer, otherwise there's no way of accessing that allocation. Don't forget to delete those allocations tho, otherwise you will get a memory leak, an error that occurs when the heap memory is overused and not deleting when done (deallocating).
7th Sep 2025, 4:09 PM
Linux
Linux - avatar
+ 1
Sidheshwar Tiwari , dynamic memory in c++ is explained in the `introduction to c++` tutorial. > find more details in the module: `arrays and pointers`. > lesson: `dynamic memory`.
7th Sep 2025, 7:52 PM
Lothar
Lothar - avatar