Java Reference
In-Depth Information
The form of mark and sweep just outlined is the usual sim‐
plest theoretical form of the algorithm. As we will see in the
following sections, real garbage collectors do more work than
this. Instead, this description is grounded in basic theory and
is designed for easy understanding.
As all objects are allocated from the allocation table, GC will trigger before the heap
gets full. In this description of mark and sweep, GC requires exclusive access to the
entire heap. This is because application code is constantly running, creating, and
changing objects, which could corrupt the results.
In Figure 6-1 , we show the effects of trying to garbage collect objects while applica‐
tion threads are running.
Figure 6-1. Heap mutation
 
Search WWH ::




Custom Search