Mark and sweep

Java's initial garbage collection algorithm, mark and sweep, used a simple two-step process:

  1. Java first step, mark, is to step through all objects that have accessible references, marking those objects as alive.
  2. The second step, sweep, involves scanning the sea for any object that is not marked.

As you can readily determine, the mark and sweep algorithm seems effective, but probably not very efficient due to the two-step nature of this approach. This eventually lead to a Java garbage collection system with vastly improved efficiencies.