The heap: Unused program memory that can be used when the program runs to dynamically allocate the memory. | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

The heap: Unused program memory that can be used when the program runs to dynamically allocate the memory.

can any one explain this?

4th Jul 2018, 2:16 PM
Ahmad Mustafeen
Ahmad Mustafeen - avatar
2 Answers
+ 4
The heap segment (also known as the “free store”) keeps track of memory used for dynamic memory allocation. In C++, when you use the new operator to allocate memory, this memory is allocated in the application’s heap segment. The address of this memory is passed back by operator new, and can then be stored in a pointer. You do not have to worry about the mechanics behind the process of how free memory is located and allocated to the user. However, it is worth knowing that sequential memory requests may not result in sequential memory addresses being allocated! http://www.learncpp.com/cpp-tutorial/79-the-stack-and-the-heap/
4th Jul 2018, 3:18 PM
Agent
Agent - avatar
+ 2
Heap memory is simply the memory that is left over after the program was loaded and the Stack memory was allocated. It may (or may not) include global variable space (it's a matter of convention). from: https://stackoverflow.com/questions/5836309/stack-memory-vs-heap-memory
4th Jul 2018, 3:15 PM
Agent
Agent - avatar