Mark and sweep is the basic operation of reclaiming memory, and it is done in two stages:
All objects that are alive in the generation being garbage collected and in younger generations are marked as alive. (Alive means pointed to by some other live object.)
All unmarked objects in the generations being garbage collected are added to the free blocks, and all marked objects are unmarked.
A mark and sweep operation is always on all the generations from 0 to a specific number.
A mark and sweep operation can be caused explicitly by calling