Java Reference
In-Depth Information
avoid that is short-lived objects will end up filling the old generation, causing full GCs to oc-
cur too frequently.
In GC logs taken with the throughput collector, the only hint for that condition is this line:
Desired survivor size 39059456 bytes, new threshold 1 (max 15)
[PSYoungGen: 657856K->35712K(660864K)]
1659879K->1073807K(2059008K), 0.0950040 secs]
[Times: user=0.32 sys=0.00, real=0.09 secs]
The desired size for a single survivor space here is 39 MB out of a young generation of 660
MB: the JVM has calculated that the two survivor spaces should take up about 11% of the
young generation. But the open question is whether that is large enough to prevent overflow.
There is no definitive answer from this log, but the fact that the JVM has adjusted the tenur-
ing threshold to 1 indicates that it has determined it is directly promoting most objects to the
old generation anyway, so it has minimized the tenuring threshold. This application is prob-
ably promoting directly to the old generation without fully using the survivor spaces.
When G1 or CMS is used, more informative output is obtained:
Desired survivor size 35782656 bytes, new threshold 2 (max 6)
- age 1: 33291392 bytes, 33291392 total
- age 2: 4098176 bytes, 37389568 total
The desired survivor space is similar to the last example—35 MB—but the output also
shows the size of all the objects in the survivor space. With 37 MB of data to promote, the
survivor space is indeed overflowing.
Whether or not this situation can be improved upon is very dependent on the application. If
the objects are going to live longer than a few more GC cycles, they will eventually end up in
the old generation anyway, so adjusting the survivor spaces and tenuring threshold won't
really help. But if the objects would go away after just a few more GC cycles, then some per-
formance can be gained by arranging for the survivor spaces to be more efficient.
If the size of the survivor spaces is increased (by decreasing the survivor ratio), then memory
is taken away from the eden section of the young generation. That is where the objects actu-
ally are allocated, meaning fewer objects can be allocated before incurring a minor GC. So
that option is usually not recommended.
Search WWH ::




Custom Search