Dynamic Memory Allocation

In this chapter, we will delve into a key aspect of system programming on a modern OS—the management of dynamic (runtime) memory allocation and deallocation. We'll first cover the basic glibc APIs used to allocate and free memory dynamically. We'll then move beyond these basics, examining the program break within the VAS and the behavior of malloc(3) under differing circumstances.

We will then immerse the reader in a few advanced discussions: demand-paging, memory locking and protection, and the usage of the alloca API.

Code examples provide the reader with an opportunity to explore these topics in a hands-on manner.

In this chapter, we will cover the following topics:

  • Basic glibc dynamic memory-management APIs ...

Get Hands-On System Programming with Linux 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.