Stop and Copy Garbage Collection Algorithm
This article, Stop and Copy Garbage Collection Algorithm, has recently been created via the Articles for creation process. Please check to see if the reviewer has accidentally left this template after accepting the draft and take appropriate action as necessary.
Reviewer tools: Inform author |
(Stop and Copy) Copy Garbage Collection Algorithm - Computer Science
(Stop and Copy) Copy Garbage Collection Algorithm - Computer Science is
Here, we describe the Copy Garbage Collection Algorithm - a garbage collection algorithm/approach used in computer programming and studied in computer science courses, that will collect and free up garbage memory, as well as de-fragmenting the memory segment. When implemented, the algorithm will split the programs memory heap into 2 equal partitions. One side is classified as live, and the other dead. The live partition holds all active objects, whereas the dead region is unoccupied.
When the program has exhausted the memory capacity in the live partition, the program is suspended and the Copy Garbage Collection Algorithm is invoked. The algorithm will first copy all the live objects within the live partition over to the dead partition. Any handles or references to these live objects being moved will be updated to reflect the objects new location in memory.
After the copy is completed, we will see that the active roles of the 2 partitions have been reversed; The dead partition now holsters the alive memory objects, and the dead partition is inactive. The algorithm works by only copying the live elements from the live partition over to the new area, and thus, the garbage objects are left behind to be overwritten at the next invocation of the algorithm.[1]
As the Copy Algorithm copies the live objects from one side to the other, it places them contiguously in memory, and therefore, intrinsically de-fragments the memory.
Drawbacks of the Copy Algorithm are as follows: Firstly, the algorithm requires that all live objects be copied each time garbage collection is required, which could lead to long wait times if a program has a large memory heap, with many live/active objects. Secondly, we see that the Copy Algorithm requires double the amount of memory as the program will request. In the normal operations of the program, only half of this memory is being used, as the other half is sitting unallocated waiting for garbage collection to be invoked.[2]
References
- http://www.cs.princeton.edu/courses/archive/spr96/cs441/notes/l14.html
- http://c2.com/cgi/wiki?StopAndCopy
- http://dl.acm.org/citation.cfm?id=91597
- Parhami, Behrooz (2005). Computer Architecture - From Microprocerssors to Supercomputers. Oxford University Press. ISBN 978-0-19-515455-9.
{{cite book}}
: Unknown parameter|month=
ignored (help) - Levitin, Anany (2007). Introduction to The Design and Ananlysis of Algorithms. Pearson Education Inc. ISBN 0-321-35828-7.
{{cite book}}
: Unknown parameter|month=
ignored (help) - Stallins, William (2012). Operating Systems - Internals and Design Prinicples - 7th Edition. Pearson Education Inc. ISBN 978-0-13-230998-1.
{{cite book}}
: Unknown parameter|month=
ignored (help)