(defmethod mark-some-roots ((heap mark-and-sweep-heap) amount)
;; Mark some roots and their descendants as alive.
;; (This may add new roots.)
(let ((work-done 0))
(loop while (and (roots heap) (< work-done amount))
do (let ((root (pop (roots heap))))
(incf work-done (mark-root heap root))))
(when (null (roots heap))
;; We've finished marking roots. Move to the next step.
(setf (state heap) :sweeping-heap))
;; Return the amount of work done.
work-done))
Source Context