Java Reference
In-Depth Information
Another possibility is to increase the size of the young generation. That can be counterpro-
ductive in this situation: objects might be promoted less often into the old generation, but
since the old generation is smaller, the application may do full GCs more often.
If the size of the heap can be increased altogether, then both the young generation and the
survivor spaces can get more memory, which will be the best solution. A good process is to
increase the heap size (or at least the young generation size) and to decrease the survivor ra-
tio. That will increase the size of the survivor spaces more than it will increase the size of
eden. The application should end up having roughly the same number of young collections
as before. It should have fewer full GCs, though, since fewer objects will be promoted into
the old generation (again, assuming that the objects will no longer be live after a few more
GC cycles).
If the sizes of the survivor spaces have been adjusted so that they never overflow, then ob-
jects will only be promoted to the old generation after the MaxTenuringThreshold is
reached. That value can be increased to keep the objects in the survivor spaces for a few
more young GC cycles. But be aware that if the tenuring threshold is increased and objects
stay in the survivor space longer, there will be less room in the survivor space during future
young collections: it is then more likely that the survivor space will overflow and start pro-
moting directly into the old generation again.
QUICK SUMMARY
1. Survivor spaces are designed to allow objects (particularly just-allocated objects)
to remain in the young generation for a few GC cycles. This increases the probab-
ility the object will be freed before it is promoted to the old generation.
2. If the survivor spaces are too small, objects will promoted directly into the old
generation, which in turn causes more old GC cycles.
3. The best way to handle that situation is to increase the size of the heap (or at least
the young generation) and allow the JVM to handle the survivor spaces.
4. In rare cases, adjusting the tenuring threshold or survivor space sizes can prevent
promotion of objects into the old generation.
Search WWH ::




Custom Search