Copying algorithms are tracing algorithms that divide the heap into multiple regions; one object region in which objects are created, and one or more free space regions (which are ignored, ie. objects are never created in these regions). When the object space becomes full, all live objects are moved to the free space. Now the free space becomes the object space, and the old object space becomes the free space. Since objects are placed contiguously in the new region, holes (fragments) are not formed.
The most commonly used copying algorithm is known as stop and copy, which uses one object region and one free space region. When the object region becomes full, the (Java) program is paused until live objects are copied into the free space. The program is restarted after the copying phase.
Copying algorithms have an advantage over compacting algorithms in that the address of object references does not change when the objects are moved.
Discuss this post in the learning forum.
- Buy programming books from our Amazon.com powered storefront.
- Earn as you browse. Sign up for Algoco.
Note: This text was originally posted on my earlier blog at http://www.adaptivelearningonline.net