Mark-Sweep
The Mark-Sweep algorithm is a garbage collection technique used in programming languages to manage memory. It works in two phases: first, it marks all reachable objects in memory, identifying which ones are still in use. This is done by traversing the object graph, starting from root references.
In the second phase, the algorithm sweeps through the memory, collecting and freeing up space occupied by unmarked objects. This helps prevent memory leaks and optimizes memory usage, ensuring that programs run efficiently. The Mark-Sweep method is commonly used in languages like Java and Python.