Learning goals of this exercise
In this exercise you will learn:
Background for this exercise
Please see Exercise 1 for an overview of running
the javaperf GUI launcher.
There are several ways to set the ratio of young gen to max heap.
The technique used in these exercises is the most straightforward: we
simply set the young gen and max heap sizes directly. It's also
possible to set this ratio with -XX:NewRatio
Steps to follow
compiler=
|
. You will see the Java 2D Demo application start.... Immediately click on the "Transforms" tab.
Then click into the "Shear" area so it fills the entire window.![[Stop]](Stop.png)
Summary
How do you know when you
have a bad young/old gen ratio?
The best way is to calculate the ratio based on your command line
arguments (or monitor the real application). In this example we
set 12 MB for the heap with 4 MB for the new gen. That leaves 8
MB for the old gen. We notice that about 5.1 MB worth of objects
stay alive in the old gen (leaving only 2.9 MB for promoted
objects). But the size of Eden and one survivor space are just
under 4 MB!!! That means that when a minor GC starts the
collector realizes that if all those young objects get promoted it will
run out of space! That's why a major collection happens to insure
that we can handle all objects that may still be alive. Other
signs of this 'promotion guarantee problem' are if the number of minor
GC's tracks the number of full GC's very closely (and if you notice
that a full GC occurs at the same time as a minor GC).
Why is small old gen (bad NewRatio) a
problem? As you can tell we are spending 5x the amount of time
optimally spent in GC (a whopping 10%). When the NewRatio is too
big then all the efficiency of minor collections is lost. Of
course another potential problem in having the old gen too small is
that there simply may not be enough space for all the live
objects. This can be true even if the NewRatio is set
appropriately. In this case look for "out of memory" errors in
the log file. In fact, this is the focus of the next exercise.
Next Steps
This lab documentation is licensed under a
Creative Commons Attribution-NonCommercial-ShareAlike 2.5 License.