Image for Mark & Sweep

Mark & Sweep

Mark and Sweep is a method used by computer programs to manage memory efficiently. It works in two steps: first, it "marks" all objects that are still in use by the program, starting from certain reference points. Then, it "sweeps" or scans through the memory to identify and remove objects that weren't marked, meaning they are no longer needed. This process helps free up memory space, preventing clutter and potential crashes, ensuring the program runs smoothly and efficiently.