mark-and-sweep

The garbage collection method that marks every object reachable from the roots, then sweeps away everything unmarked.

In more detail

It correctly frees circular references that nothing outside reaches. Modern engines are generational: they collect short-lived young objects often and cheaply, and older objects less often.

Related terms

Taught in

References