Want a Free Job Posting?

Buy a job posting today and the second one is on us. For a limited time only. Act Now.

Interview Question


design garbage collection system


Interview Answer

1 Answer


The simplest concept is (naive) `mark and sweep`: one walk through the graph of objects (starting from the `root` objects that are known to be reachable), `marking` all the objects reached in the walk; then a `sweep` through all existing objects, deleting all the unmarked ones (and unmarking the marked ones to be ready for the next cycle). Many improvements are possible, esp. to allow incremental or concurrent GC, but they take quite a bit longer to explain;-).

Alex on May 19, 2013

Add Answers or Comments

To comment on this, Sign In or Sign Up.