Netflix

www.netflix.com
Employer Engaged

Interview Question

Senior Software Engineer Interview

design garbage collection system

Answer

Interview Answer

1 Answer

0

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.