🧹Mark sweep garbage collection works by first identifying all the non-heap references, marking reachable objects, and then sweeping up the unmarked objects.
🔍Roots are the non-heap references that the collector uses to keep track of live objects and are essential for the mark phase of mark sweep garbage collection.
🌐During the mark phase, the collector follows reference fields in heap objects to mark them as live and adds them to the work list.
💥The sweeping phase of mark sweep garbage collection iterates through all objects on the heap and collects any unmarked objects as garbage.
🔄Mark sweep garbage collection can be a stop-the-world process, meaning it temporarily pauses the program execution, but can be optimized to minimize downtime.