Memory management is mainly related to memory allocation and the release of allocated memory when it is no longer needed. Memory allocation can be performed either statically or dynamically. Up to this point, our program variables are stored in fixed size memory, statically allocated. In this chapter, we’ll show you how to allocate memory dynamically during program execution in order to form flexible data structures, like stacks, queues, and linked lists.
When a program runs, it asks for memory resources from the operating system. Various operating systems and compilers use their own models to manage the available memory. Typically, the system memory is divided into four parts: