-1

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.

trincot
  • 317,000
  • 35
  • 244
  • 286
Jason
  • 2,198
  • 3
  • 23
  • 59

2 Answers2

1

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 and delete ). 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.

songyuanyao
  • 169,198
  • 16
  • 310
  • 405
0

Detailed Explaination

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.

Community
  • 1
  • 1
Rajnish
  • 419
  • 6
  • 21