The sharp peak at the left represents objects that can be reclaimed (in other words, have "died") shortly after being allocated. The byte count on the y-axis is the total bytes in objects with the corresponding lifetime. The x-axis is object lifetimes measured in bytes allocated. The blue area in Figure 3-1, "Typical Distribution for Lifetimes of Objects" is a typical distribution for the lifetimes of objects. The most important of these observed properties is the weak generational hypothesis, which states that most objects survive for only a short period of time. While naive garbage collection examines every live object in the heap, generational collection exploits several empirically observed properties of most applications to minimize the work required to reclaim unused (garbage) objects. The virtual machine incorporates a number of different garbage collection algorithms that are combined using generational collection. The time this approach takes is proportional to the number of live objects, which is prohibitive for large applications maintaining lots of live data. Any objects left over are considered garbage. The most straightforward garbage collection algorithms iterate over every reachable object. Garbage collectors make assumptions about the way applications use objects, and these are reflected in tunable parameters that can be adjusted for improved performance without sacrificing the power of the abstraction.Īn object is considered garbage when it can no longer be reached from any pointer in the running program. However, when garbage collection is the principal bottleneck, it is useful to understand some aspects of this hidden implementation. One strength of the Java SE platform is that it shields the developer from the complexity of memory allocation and garbage collection.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |