Dynamic Memory Allocation and Garbage Collection

Background Material



When the amount of memory needed for a computation is not known at compile time, memory will need to be allocated dynamically. As memory is needed a sufficiently large chunk of memory is requested (e.g. malloc, new) and if possible the request is made from system memory called the heap. When the chunk of memory is no longer needed it can either be explicitly returned (e.g. free) or it becomes garbage and we can leave it to the system to reclaim the unused memory when there amount of space in the heap becomes too small. The process of collecting memory that is no longer being used is called garbage collection.

In this lecture we present an overview of techniques for dynamic memory allocation and garbage collection.


  1. cons cells and list allocation (uniform size)
  2. extent and overlap
  3. garbage collection (mark and sweep)
  4. variable size allocation
  5. reference counting



Created: April 10, 2008 (revised April 20, 2010) by jjohnson AT cs DOT drexel DOT edu