What is the technical definition of “dynamic stora

2019-09-21 08:53发布

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.

2条回答
对你真心纯属浪费
2楼-- · 2019-09-21 09:14

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.

查看更多
Luminary・发光体
3楼-- · 2019-09-21 09:27

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.

查看更多
登录 后发表回答