Memory management - Wikipedia#HEAP

🖼️ ➺

The task of fulfilling an allocation request consists of locating a block of unused memory of sufficient size. Memory requests are satisfied by allocating portions from a large pool1 of memory called the heap2 or free store. At any given time, some parts of the heap are in use, while some are “free” (unused) and thus available for future allocations. In the C language, the function which allocates memory from the heap is called malloc and the function which takes previously allocated memory and marks it as “free” (to be used by future allocations) is called free.3

Several issues complicate the implementation, such as external fragmentation, which arises when there are many small gaps between allocated memory blocks, which invalidates their use for an allocation request. The allocator’s metadata can also inflate the size of (individually) small allocations. This is often managed by chunking. The memory management system must track outstanding allocations to ensure that they do not overlap and that no memory is ever “lost” (i.e. that there are no “memory leaks”).

Printed 2026-07-04.

(echo:: @ )

Footnotes

  1. In some operating systems, e.g., OS/360, the free storage may be subdivided in various ways, e.g., subpools in OS/360, below the line, above the line and above the bar in z/OS.

  2. Not to be confused with the unrelated heap data structure.

  3. A simplistic implementation of these two functions can be found in the article “Inside Memory Management”.