This chapter focused upon both the simple and more advanced aspects of dynamic memory management for C application developers on the Linux OS. In the initial section, the basic glibc dynamic memory-management APIs and their correct usage in code was dealt with.
We then moved on to more advanced topics such as the program break (and the sbrk(3) API), how malloc(3) behaves internally when allocating memory of differing sizes, and the key concept of demand-paging. Then, we delved into the APIs that perform memory locking and memory region protection, and reasons to use them. Finally, we looked at alloca(3), the alternate API. Several code examples were used to solidify the concepts that were learned. The next chapter will cover a really important topic—the variety of memory issues (defects) that can arise on Linux due to poor programming practices with the memory APIs...