Java Reference
In-Depth Information
Global pointer
Global pointer
Internal pointer
From Space
Object 1
Object 3
Object 5
To Space
Figure 12.18: Copying Garbage Collection (a)
Object 5
From Space
Internal pointer
Object 3
Object 1
To Space
Global pointer
Global pointer
Figure 12.19: Copying Garbage Collection (b)
heap allocation resumes just beyond the last copied object. This is illustrated
in Figure 12.20.
The biggest advantage of copying collectors is their speed. Only live
objects are copied; deallocation of dead objects is essentially free. In fact,
garbage collection can be made, on average, as fast as you wish simply by
making the heap bigger. As the heap gets bigger, the time between collections
increases, reducing the number of times a live object must be copied. In the
limit, objects are never copied, so garbage collection becomes free!
Of course, we cannot increase the size of heap memory to infinity. In
fact, we do not want to make the heap so large that paging is required, since
swapping pages to disk is dreadfully slow.
If we can make the heap large
To Space
Internal pointer
From Space
Object 1
Object 3
Object 5
End of Heap pointer
Global pointer
Global pointer
Figure 12.20: Copying Garbage Collection (c)
 
Search WWH ::




Custom Search