Java Reference
In-Depth Information
Note that this flag does not set the number of background threads used by CMS or G1
(though it does affect that). Details on that are given in the next chapter.
QUICK SUMMARY
1. The basic number of threads used by all GC algorithms is based on the number of
CPUs on a machine.
2. When multiple JVMs are run on a single machine, that number will be too high
and must be reduced.
Adaptive Sizing
The sizes of the heap, the generations, and the survivor spaces can vary during execution as
the JVM attempts to find the optimal performance according to its policies and tunings.
This is a best-effort solution, and it relies on past performance: the assumption is that future
GC cycles will look similar to the GC cycles in the recent past. That turns out to be a reason-
able assumption for many workloads, and even if the allocation rate suddenly changes, the
JVM will readapt its sizes based on the new information.
Adaptive sizing provides benefits in two important ways. First, it means that small applica-
tions don't need to worry about overspecifying the size of their heap. Consider the adminis-
trative command-line programs used to adjust the operations of things like an application
server—those programs are usually very short-lived and use minimal memory resources.
These applications will use 16 (or 64) MB of heap even though the default heap could poten-
tially grow to 1 GB. Because of adaptive sizing, applications like that don't need to be spe-
cifically tuned; the platform defaults ensure that they will not use a large amount of memory.
Second, it means that many applications don't really need to worry about tuning their heap
size at all—or if they need a larger heap than the platform default, they can just specify that
larger heap and forget about the other details. The JVM can autotune the heap and generation
sizes to use an optimal amount of memory given the GC algorithm's performance goals. Ad-
aptive sizing is what allows that autotuning to work.
Still, doing the adjustment of the sizes takes a small amount of time—which occurs for the
most part during a GC pause. If you have taken the time to finely tune GC parameters and
the size constraints of the application's heap, adaptive sizing can be disabled. Disabling ad-
Search WWH ::




Custom Search