Tamarin::MMgc: Difference between revisions

Jump to navigation Jump to search
m
Line 410: Line 410:
In the Mark phase, all of the mark bits are cleared.  The garbage collector is aware of "roots", which are starting points from which all "live" application data should be reachable.  The collector starts scanning objects, starting at the roots and fanning outwards.  For every object it encounters, it sets the mark bit.
In the Mark phase, all of the mark bits are cleared.  The garbage collector is aware of "roots", which are starting points from which all "live" application data should be reachable.  The collector starts scanning objects, starting at the roots and fanning outwards.  For every object it encounters, it sets the mark bit.


When the Mark phase concludes, the Sweep phase begins.  In the Sweep phase, every object that wasn't marked in the Mark phase is destroyed and its memory reclaimed.  If an object didn't have its mark bit set during the Mark phase, that means it wasn't reacahable from the roots anymore, and thus was not reachable from anywhere in the application code.
When the Mark phase concludes, the Sweep phase begins.  In the Sweep phase, every object that wasn't marked in the Mark phase is destroyed and its memory reclaimed.  If an object didn't have its mark bit set during the Mark phase, that means it wasn't reachable from the roots anymore, and thus was not reachable from anywhere in the application code.


The following Flash animation illustrates the working of a mark/sweep collector:
The following Flash animation illustrates the working of a mark/sweep collector:

Navigation menu