Storage Schemes and Dynamic Allocation
You’ve seen the five schemes, excluding threaded memory, C++ uses to allocate memory for variables (including arrays and structures). They don’t apply to memory allocated by using the C++ new
operator (or by using the older C malloc()
function). We call that kind of memory dynamic memory. As you saw in Chapter 4, dynamic memory is controlled by the new
and delete
operators, not by scope and linkage rules. Thus, dynamic memory can be allocated from one function and freed from another function. Unlike automatic memory, dynamic memory is not LIFO; the order of allocation and freeing depends on when and how new
and delete
are used. Typically, the compiler uses three separate memory chunks: one for static variables ...
Get C++ Primer Plus now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.