Content deleted Content added
Ash.taunk3 (talk | contribs) Added Sample Algorithm in pseudo code |
PMLawrence (talk | contribs) Of the two most likely computer science meanings of "heap", that pointed to the wrong one; etc. |
||
Line 1:
{{Use dmy dates|date=August 2012}}
{{morefootnotes|date=April 2014}}
'''Cheney's algorithm''', first described in a 1970 [[Association for Computing Machinery|ACM]] paper by C.J. Cheney, is a method of [[garbage collection (computer science)|garbage collection]] in computer software systems.
Cheney's algorithm reclaims items as follows:
Line 12:
Once all to-space references have been examined and updated, garbage collection is complete.
The algorithm needs no stack and only two pointers outside of the from-space and to-space: a pointer to the beginning of free space in the to-space, and a pointer to the next word in to-space that needs to be examined.
The forwarding pointer (sometimes called a "broken heart") is used only during the garbage collection process
Because the strategy is to exhaust all live references, and then all references in referenced objects, this is known as a ''breadth-first'' list copying garbage collection scheme.
Line 59:
== Equivalence to tri-color abstraction ==
Cheney's algorithm is an example of a [[Tracing garbage collection#Tri-color marking|tri-color marking]] garbage collector. The first member of the gray set is the stack itself.
The algorithm moves any white objects (equivalent to objects in the from-space without forwarding pointers) to the gray set by copying them to the to-space.
When the scanning pointer reaches the free-space pointer, the gray set is empty, and the algorithm ends.
|