The following changes take effect with Java SE 5.0.
On server-class machines running
the server VM, the garbage collector (GC) has changed from
the previous serial collector (
-XX:+UseSerialGC) to a
parallel collector (
-XX:+UseParallelGC). You can
override this default by using the
command-line option to the
On server-class machines running
either VM (client or server) with the parallel garbage
-XX:+UseParallelGC) the initial heap size
and maximum heap size have changed as follows.
Larger of 1/64th of the machine's physical memory on the machine
or some reasonable minimum. Before Java SE 5.0, the default initial
heap size was a reasonable minimum, which varies by platform. You
can override this default using the
Smaller of 1/4th of the physical memory or 1GB. Before Java SE 5.0,
the default maximum heap size was 64MB. You can override this
default using the
-Xmx command-line option.
Note: The boundaries and fractions given for the heap size are correct for Java SE 5.0. They are likely to be different in subsequent releases as computers get more powerful.
The parallel garbage collector (
throws an out-of-memory exception if an excessive amount of time is
being spent collecting a small amount of the heap. To avoid this
exception, you can increase the size of the heap. You can also set
The upper limit on the amount of time spent in garbage collection in percent of total time (default is 98).
The lower limit on the amount of space freed during a garbage collection in percent of the maximum heap (default is 2).
-XX:+UseAdaptiveSizePolicyused by default with the
-XX:+UseParallelGCgarbage collector has changed to consider three goals:
The implementation checks (in this order):
By default there is no pause time goal. There are definite limitations on how well a pause time goal can be met. The pause time for a GC depends on the amount of live data in the heap. The minor and major collections depend in different ways on the amount of live data. This parameter should be used with caution. A value that is too small will cause the system to spend an excessive amount of time doing garbage collection.
-XX:GCTimeRatio=19 sets a goal of 5% of
the total time for GC and throughput goal of 95%. That is, the
application should get 19 times as much time as the collector.
By default the value is 99, meaning the application should get at least 99 times as much time as the collector. That is, the collector should run for not more than 1% of the total time. This was selected as a good choice for server applications. A value that is too high will cause the size of the heap to grow to its maximum.
Do not choose a maximum value for the heap unless you know that the heap is greater than the default maximum heap size. Choose a throughput goal that is sufficient for your application.
In an ideal situation the heap will grow to a value (less than the maximum) that will support the chosen throughput goal.
If the heap grows to its maximum, the throughput cannot be met within that maximum. Set the maximum heap as large as you can, but no larger than the size of physical memory on the platform, and execute the application again. If the throughput goal can still not be met, then it is too high for the available memory on the platform.
If the throughput goal can be met but there are pauses that are too long, select a pause time goal. This will likely mean that your throughput goal will not be met, so choose values that are an acceptable compromise for the application.