17. markingphase
markFromRoots():
initialise(worklist)
for each fld in Roots
ref ← *fld
if ref ≠ null && not isMarked(ref)
setMarked(ref)
add(worklist, ref)
mark()
initialise(worklist):
worklist ← empty
mark():
while not isEmpty(worklist)
ref ← remove(worklist)
/* ref is marked */
for each fld in Pointers (ref)
child ← *fld
if child ≠ null && not isMarked(child)
setMarked(child)
add(worklist, child)