You are viewing an old version of this page. View the current version.

Compare with Current View Page History

Version 1 Next »

JVM Types:

On machines that are not server-class machines, the default values for JVM, garbage collector, and heap sizes
are
• the client JVM
• the serial garbage collector
• Initial heap size of 4MB
• Maximum heap size of 64MB

On machines that have at least 2 CPU's and at least 2 GB of physical memory are considered server-class machines which means that by default the settings are:

    * The -server compiler
    * The -XX:+UseParallelGC parallel (throughput) garbage collector
    * The -Xms initial heap size is 1/64th of the machine's physical memory
    * The -Xmx maximum heap size is 1/4th of the machine's physical memory (up to 1 GB max).

Heap layout

The HotSpot JVM manages heap space in generations -- that is, memory pools for both new and old objects.
Memory in the Java HotSpot virtual machine is organized into three generations: a young generation, an old
generation, and a permanent generation. The new generation includes the new object space (eden), plus two survivor spaces (SS#1 and SS#2).
New objects allocate in eden. Longer-lived objects are moved from the new generation and tenured to the old generation.
hows another heap section, called the permanent generation, which holds the JVM's class and method objects.
The -XX:MaxPermSize=64m command line parameter controls the permanent generation's size.

As these objects accumulate, eventually a low memory condition occurs, forcing garbage collection to take place. When the young generation fills up, a young generation collection (sometimes referred to as a minor collection)
of just that generation is performed. When the old or permanent generation fills up, what is known as a full
collection (sometimes referred to as a major collection) is typically done. That is, all generations are collected.

Garbage collection Algorithms:

• Serial versus Parallel
• Concurrent versus Stop-the-world

Ratio of old to new generations

You can divide the heap into old and new generations using the NewRatio parameter. If you use -XX:NewRatio=5, then you create an old-to-new ratio of 5:1; the old generation occupies 5/6 of the heap while the new generation occupies 1/6 of the heap. If you increase the new generation's size, minor collections may occur less often. However, because the -Xmx parameter sets the total heap size, you also decrease the old generation's size. This may increase the frequency of major collections.

The default NewRatio for the HotSpot Client JVM is 8; the old generation occupies 8/9 of the heap while the new generation occupies 1/9

The default NewRatio for the HotSpot Server JVM is 2; the old generation occupies 2/3 of the heap while the new generation occupies 1/3, as Figure 4 above shows. The larger new generation can accommodate many more short-lived objects, thus decreasing the need for slow major collections. The old generation is still sufficiently large enough to hold many long-lived objects.

When no client or server parameter is provided, the Java HotSpot VM 1.3.1 uses its default value. The default is the first line in the jvm.cfg file, which is located in the <jvm_dir>/jre/lib directory. Rather than modifying all your startup scripts to add the -server parameter, you can make -server the first noncomment line in the file.

JVM command line options

 Options to select garbage collection
-XX:+UseSerialGC  Serial
-XX:+UseParallelGC  Parallel
-XX:+UseParallelOldGC  Parallel compacting
-XX:+UseConcMarkSweepGC Concurrent mark-sweep (CMS)

Options for Garbage Collector Statistics
-XX:+PrintGC Outputs basic information at every garbage collection.
-XX:+PrintGCDetails Outputs more detailed information at every garbage collection.
-XX:+PrintGCTimeStamps Outputs a time stamp at the start of each garbage collection event. Used with
-XX:+PrintGC or -XX:+PrintGCDetails to show when each garbage collection begins.

Heap options:
-Xms<size>        set initial Java heap size
-Xmx<size>        set maximum Java heap size
-Xss<size>        set java thread stack size
-XX:NewSize= Default initial size of the new (young) generation,in bytes.
-XX:NewRatio=n   Ratio between the young and old generations.
-XX:SurvivorRatio=n Ratio between each survivor space and Eden. For
example, if n is 7, each survivor space is one-ninth
of the young generation (not one-eighth, because
there are two survivor spaces).
-XX:MaxPermSize=n  Platform-dependent Maximum size of the permanent generation

  • No labels