Just what the title says, "What is the technical definition of dynamic storage in C++?" I'm curious as to how to discuss dynamic memory allocation on the heap without making any mistakes in my explanation.
-
2See this: http://stackoverflow.com/questions/9181782/why-are-the-terms-automatic-and-dynamic-preferred-over-the-terms-stack-and – kfx Dec 31 '15 at 18:03
-
See [basic.stc.dynamic]. – Kerrek SB Dec 31 '15 at 18:09
-
You asked quite the same question some minutes ago! – too honest for this site Dec 31 '15 at 18:57
2 Answers
From the The C++ Programming Language: Special Edition
Free store, from which memory for objects is explicitly requested by the program and where a program can free memory again once it is done with it (using
new
anddelete
). When a program needs more free store,new
requests it from the operating system. Typically, the free store (also called dynamic memory or the heap) grows throughout the lifetime of a program because no memory is ever returned to the operating system for use by other programs.

- 169,198
- 16
- 310
- 405
The heap is a bunch of memory that can be used dynamically.
Lets say you want 12kb of memory for an object then the dynamic allocator will look through its list of free space in the heap, pick out a 12kb chunk, and give it to you.
Generally, the dynamic memory allocator (malloc, new, etc.) starts at the end of memory and works backwards.
-
There is no requirement for a heap. There is no specification for where the heap starts nor how it is manipulated. – Thomas Matthews Dec 31 '15 at 18:24
-
Yes there is no enforced pattern but just for explanation purpose we can assume it. – Rajnish Dec 31 '15 at 18:28