design garbage collection system
Anonymous
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;-).
Check out your Company Bowl for anonymous work chats.