Chapter 17: Understanding Memory Allocation and Lifetime
Every instance of a value—be it a literal, an intrinsic data type, or a complex data type—exists in memory. Here, we will explore various ways in which memory is allocated. The different mechanisms for memory allocation are called storage classes. In this chapter, we will review the storage class we've been using thus far, that of automatic storage, as well as introducing the static storage class. We will also explore the lifetime of each storage class, as well as introduce the scope of a storage class—internal versus external storage.
After exploring automatic and static storage classes, this chapter paves the way for a special and extremely flexible storage class—that of dynamic memory allocation. Dynamic memory allocation is so powerful and flexible that it will be introduced and discussed in more depth in Chapter 18, Using Dynamic Memory Allocation, with the creation and manipulation of...