Contents    Page-10    Prev    Next    Page+10    Index   

Mark-And-Sweep Garbage Collection

Mark-and-sweep garbage collection first marks all storage cells that are in use, then sweeps up all unmarked cells. Symbol cells are marked, and all pointers from the symbols are followed using the following recursive algorithm:

  1. If the pointer points to a Symbol or to a marked cell, do nothing.

  2. Otherwise (pointer points to a cons Cell),
    1. Mark the cell itself.

    2. Apply the marking algorithm to the first of the cell.

    3. Apply the marking algorithm to the rest of the cell.