JAVA6--JVM parameter Options

Source: Internet
Author: User
Tags print format jconsole java throws

Non-stationary option usage instructions

-xx:+<option> Enable options

-xx:-<option> do not enable options

-xx:<option>=<number> sets a numeric type value for the option, which can be followed by a unit such as 32k, 1024m, 2g
-xx:<option>=<string> sets a string value for the option, such as-xx:heapdumppath=./dump.core

Behavior options

Options

Default values and Restrictions

Describe

-xx:-allowusersignalhandlers

Limited to Linux and Solaris, not enabled by default

Allows the installation of a signal processor for a Java process.


Java signal Processing related knowledge, see http://kenwublog.com/java-asynchronous-notify-based-on-signal

-xx:-disableexplicitgc

Not enabled by default

Suppresses explicitly calling System.GC () at run time.

When this option is turned on, the GC trigger time will be fully controlled by garbage collector.
Note: The code you are familiar with does not call System.GC () and does not mean that the framework tool you are relying on is not being used.

RMI, for example, displays the GC to prevent itself from oom, without the knowledge of most users.

Carefully weigh the impact of disabling.

-xx:-relaxaccesscontrolcheck

Not enabled by default

In the class validator, relax the check for access control.

The effect is similar to the setaccessible in reflection.

-xx:-useconcmarksweepgc

Not enabled by default

Enable the CMS low-pause garbage collector.

Information see: Http://kenwublog.com/docs/CMS_GC.pdf

-xx:-useparallelgc

-server when enabled

In other cases, the default is not enabled

The strategy uses parallel cleanup for the Cenozoic, with the old generation using a single-threaded mark-sweep-compact garbage collector.

-xx:-useparalleloldgc

Not enabled by default

The strategy is to use a parallel purge garbage collector for both the old and the new generation.

-xx:-useserialgc

-client when enabled

In other cases, the default is not enabled

Use the serial garbage collector.

-xx:+usesplitverifier

JAVA5 not enabled by default

JAVA6 enabled by default

Use the new class type validator.


What are the characteristics of the new class type validator?
The new class type validator splits the old verification step into two steps:
1, type inference.
2, type check.

The new type Checker improves ClassLoader performance by embedding type information into bytecode at compile time at Javac, omitting the step of type inference.

Classload order (for reference)
Init, resove, prepare, verify , load


Associated options:
-xx:+failovertooldverifier

-xx:+failovertooldverifier

Java6 new introduction option, enabled by default

If the new class checker fails, the old validator is used.

 

Why did it fail?

Because JDK6 is most backward-compatible to JDK1.2, and JDK1.2 's class info differs greatly from the info in JDK6, the new validator may fail the checksum.


Association options:
-xx:+usesplitverifier

-xx:+handlepromotionfailure     

Java5 is previously not enabled by default, Java6

Turns off the new generation collection guarantee.


What is the new generation collection guarantee?
In an idealized minor GC, the active objects in Eden and first Survivor are copied to the second Survivor.
However, Second survivor does not necessarily accommodate all active objects copied from the E and F zones.

To ensure that the minor GC can be completed successfully, the GC needs to retain an extra chunk of memory in the older generation that is sufficient to accommodate all active objects.
This reserved operation is called the New Generation Collection guarantee (Generation Guarantee). If the reservation operation cannot be completed, the major GC (full GC) is still triggered.

Why do you want to turn off the new generation collection guarantee?
Because of the amount of space reserved in older generations, it cannot be calculated accurately.

To ensure that extreme conditions occur, the GC references the worst-case cenozoic memory footprint, Eden+first Survivor.

This strategy is undoubtedly wasting older generations of memory and, from a timing perspective, triggering the full GC in advance.

To avoid this, the JVM allows developers to manually turn off the new generation of collection guarantees.

 

When this option is turned on, the minor GC will no longer provide a new generation of collection guarantees, but instead throws a promotion failed exception when a survior or older generation is not enough.

-xx:+usespinning

java1.4.2 and 1.5 need to be enabled manually, JAVA6 is enabled by default

Enables multi-threaded spin lock optimizations.


Principle of spin lock optimization

As you know, the multithreading security of Java is implemented based on the lock mechanism, and the performance of lock is often unsatisfactory.
The reason is that Monitorenter and Monitorexit, the two bytecode primitives that control multithreading synchronization, are implemented by the JVM relying on operating system mutexes (mutexes).
A mutex is a resource-intensive operation that causes a thread to hang and must be re-dispatched back to the original thread in a short period of time.

To avoid entering the OS mutex, JAVA6 's developers have proposed spin lock optimizations.

The principle of spin lock optimization is to detect the release of a lock by a certain number of CAs spins before the thread enters the OS mutex.

If the lock has been released before the spin count has reached its preset value, the current thread holds the lock immediately.

The principle of CAs detection lock see: Http://kenwublog.com/theory-of-lightweight-locking-upon-cas


Associated options:
-xx:preblockspin=10

-xx:preblockspin=10

-xx:+usespinning must be enabled first, it has been enabled by default for JAVA6, the default spin 10 times

Controls the spin times of multi-threaded spin lock optimizations. (What is spin lock optimization?) See the description at-xx:+usespinning)


Associated options:
-xx:+usespinning

-xx:+scavengebeforefullgc

Enabled by default

Triggers a minor GC before the full GC.

-xx:+usegcoverheadlimit

Enabled by default

Limit the elapsed time of the GC. If the GC takes too long, it throws an oom.

-xx:+usetlab

1.4.2 before and when using the-client option, the default is not enabled and the remaining versions are enabled by default

Thread local cache is enabled.

-xx:+usethreadpriorities

Enabled by default

Uses the priority of the local thread.

-xx:+usealtsigs

Limited to Solaris, enabled by default

To prevent collisions with other applications that send signals, alternate signals are allowed to replace SIGUSR1 and SIGUSR2.

-xx:+useboundthreads

Limited to Solaris, enabled by default

Binds all user threads to the kernel thread.
Reduce the number of threads entering starvation (not getting any CPU time).

-xx:+uselwpsynchronization

Limited to Solaris, enabled by default

Replace thread synchronization with lightweight processes (kernel threads).

-xx:+maxfdlimit

Limited to Solaris, enabled by default

Set the Java process available file descriptor to the maximum allowable value for the operating system.

-xx:+usevminterruptibleio

Limited to Solaris, enabled by default

In Solaris, the run-time interrupt thread is allowed.

Performance Options

Options and default values

Default values and Restrictions

Describe

-xx:+aggressiveopts

Introduced after JDK 5 update 6, but needs to be enabled manually.

JDK6 is enabled by default.

Enable the latest tuning results for the JVM development team. For example compile optimization, biased lock, parallel old generation collection, etc.

-xx:compilethreshold=10000

1000

By JIT compiler, the method is compiled into the trigger threshold of machine code, can be understood as the number of calls method, such as 1000 times, the method compiled into machine code.

-xx:largepagesizeinbytes=4m

Default 4m

AMD64 bit: 2m

Sets the memory page size for heap memory.

How to adjust memory pages and how to improve the performance, see Http://kenwublog.com/tune-large-page-for-jvm-optimization

-xx:maxheapfreeratio=70

70

After GC, if the free heap memory is found to account for 70% of the entire estimated upper limit value, the estimated upper limit is shrunk.

What is the estimated upper limit value?

At startup, the JVM will request the address space of the maximum value (-xmx specified value), but most of the space will not be allocated immediately (virtual).

They will remain until the JVM discovers that a portion of the memory is being allocated from virtual before it is actually occupied near the assigned upper limit during the run.

The assigned upper limit value mentioned here can also be called the estimated upper limit value.


The benefit of introducing an estimated upper value is that you can effectively control the size of the heap. The smaller the heap, the higher the efficiency of the GC.

Note: The size of the estimated upper limit value must be less than or equal to the maximum value.

-xx:maxnewsize=size

1.3.1 Sparc:32m

1.3.1 X86:2.5m

The Cenozoic represents the maximum value of the entire heap memory.

-xx:maxpermsize=64m

After 5.0: The size of the VMS will increase the default value of 30%

1.4 amd64:96m

1.3.1-client:32m

Other default 64m

The Perm (commonly known as the method area) occupies the maximum value of the entire heap memory.

-xx:minheapfreeratio=40

40

After GC, if the free heap memory is found to account for 40% of the entire estimated upper limit, the upper limit is increased.

(What is the estimated upper value?) See the description at-xx:maxheapfreeratio)

Associated options:

-xx:maxheapfreeratio=70

-xx:newratio=2

Sparc-client:8

X86-server:8

X86-client:12

-client:4 (1.3)

8 (1.3.1+)

X86:12

Other default 2

The heap memory occupancy ratio of the Cenozoic and older generations.

For example, 2 For example 2 indicates that the Cenozoic represents 1/2 of the old generation, accounting for 1/3 of the total heap memory.

-xx:newsize=2.125m

After 5.0: The size of the VMS will increase the default value of 30%

x86:1m

x86, 5.0 after: 640k

Other default 2.125m

The default value of the new generation estimate upper limit. (What is the estimated upper value?) See the description at-xx:maxheapfreeratio)

-xx:reservedcodecachesize=32m

Solaris 64-bit, AMD64,-server x86:48m

Before 1.5.0_06, the Solaris 64-bit amd64:1024m

Other default 32m

Sets the maximum value of the code cache, which is used at compile time.

-xx:survivorratio=8

Solaris Amd64:6

Sparc in 1.3.1:25

Solaris Platforms 5.0 ago: 32

Other default 8

The occupancy ratio of Eden to survivor. For example, 8 indicates that a survivor area occupies 1/8 of the Eden Memory, or 1/10 of the Cenozoic memory, why not 1/9?

Because our new generation has 2 survivor, namely S1 and S22. So survivor is a total of new generation of memory 2/10,eden and Cenozoic accounted for 8/10.

-xx:targetsurvivorratio=50

50

The actual amount of survivor space used. The default is 50%, up to 90%.

-xx:threadstacksize=512

sparc:512

Solaris x86:320 (5.0 ago 256)

Sparc bit:1024

Linux amd64:1024 (5.0 ago 0)

Other default 512.

Thread stack size

-xx:+usebiasedlocking

Introduced after JDK 5 update 6, but needs to be enabled manually.

JDK6 is enabled by default.

Turn on biased locking.

Biased locking principle See http://kenwublog.com/theory-of-java-biased-locking

-xx:+usefastaccessormethods

Enabled by default

Optimizes the getter method performance of the original type.

-xx:-useism

Enabled by default

Enable the ISM for Solaris.

See Intimate Shared Memory.

-xx:+uselargepages

Introduced after JDK 5 update 5, but needs to be enabled manually.

JDK6 is enabled by default.

Enables large memory paging.

How to adjust memory pages and how to improve the performance, see Http://kenwublog.com/tune-large-page-for-jvm-optimization

Association options

-xx:largepagesizeinbytes=4m

-xx:+usempss

Before 1.4.1: not enabled

The remaining versions are enabled by default

Solaris MPSS is enabled and cannot be used concurrently with ISM.

-xx:+stringcache

Enabled by default

Enables string caching.

-xx:allocateprefetchlines=1

1

An option related to machine code instruction pre-reading, with less data and no explanation for this document. Interested friends Please read the official doc by yourself.

-xx:allocateprefetchstyle=1

1

An option related to machine code instruction pre-reading, with less data and no explanation for this document. Interested friends Please read the official doc by yourself.

Debugging options

Options and default values

Default values and Restrictions

Describe

-xx:-citime

1.4 introduced.

Enabled by default

Printing JIT compiler compilation time-consuming.

-xx:errorfile=./hs_err_pid<pid>.log

Introduced in Java 6.

If the JVM crashed, output the error log to the specified file path.

-xx:-extendeddtraceprobes

Java6 introduced, limited to Solaris

Not enabled by default

Enable DTrace Diagnostics.

-xx:heapdumppath=./java_pid<pid>.hprof

The default is the Java process startup location, which is User.dir

The storage file path for the heap memory snapshot.

What is a heap memory snapshot?

When the Java process is forcibly terminated by the OS due to oom or crash, a heap memory snapshot file in Hprof (heap profling) format is generated. This file is used for offline debugging, diagnosing, and finding problems.

File names are generally

Java_<pid>_<date>_<time>_heapdump.hprof

Parsing snapshot files, you can use Jhat, Eclipse mat,gdb and other tools.

-xx:-heapdumponoutofmemoryerror

1.4.2 Update12 and 5.0 update 7 were introduced.

Not enabled by default

In Oom, output a Dump.core file that records the heap memory snapshot at that time (what is a heap memory snapshot?). See the description at-xx:heapdumppath).

-xx:onerror= "<cmd args>;<cmd args>"

1.4.2 Update 9 introduced

When Java throws an error each time, the specified command-line instruction set is run. The instruction set is related to the OS environment, most of which are bash scripts under Linux and DOS batches under Windows.

-xx:onoutofmemoryerror= "<cmd args>;
<cmd args> "

1.4.2 Update 12 and JAVA6 are introduced

When an oom occurs for the first time, run the specified command-line instruction set. The instruction set is related to the OS environment, most of which are bash scripts under Linux and DOS batches under Windows.

-xx:-P Rintclasshistogram

Not enabled by default

Under Windows, the class histogram is printed when you press Ctrl-break or Linux to perform kill-3 (send Sigquit signal).

The Jmap–histo PID also achieves the same function.

See http://java.sun.com/javase/6/docs/technotes/tools/share/jmap.html

-xx:-P Rintconcurrentlocks

Not enabled by default

At the same time as thread dump, print the lock state of the java.util.concurrent.

The Jstack–l PID also achieves the same function.

See http://java.sun.com/javase/6/docs/technotes/tools/share/jstack.html

-xx:-P Rintcommandlineflags

5.0 introduced, not enabled by default

When Java starts, print the currently enabled non-stationary JVM options to stdout.

For example:

-xx:+useconcmarksweepgc-xx:+heapdumponoutofmemoryerror-xx:+doescapeanalysis

-xx:-P rintcompilation

Not enabled by default

The information to be JIT-compiled for the StdOut printing method.

For example:

1 Java.lang.string::charat (bytes)

-xx:-P RINTGC

Not enabled by default

Turn on GC log printing.

Printing formats such as:

[Full GC 131115k->7482k (1015808K), 0.1633180 secs]

This option is enabled dynamically through the Com.sun.management.HotSpotDiagnosticMXBean API and Jconsole.

See http://java.sun.com/developer/technicalArticles/J2SE/monitoring/#Heap_Dump

-xx:-P Rintgcdetails

1.4.0 introduced, not enabled by default

Print the details of GC reclamation.

Printing formats such as:

[Full GC (System) [tenured:0k->2394k (466048K), 0.0624140 secs] 30822k->2394k (518464K), [perm:10443k->10443k ( 16384K)], 0.0625410 secs] [times:user=0.05 sys=0.01, real=0.06 secs]

This option is enabled dynamically through the Com.sun.management.HotSpotDiagnosticMXBean API and Jconsole.

See http://java.sun.com/developer/technicalArticles/J2SE/monitoring/#Heap_Dump

-xx:-P rintgctimestamps

Default does not enable

Printing GC pauses time-consuming.

 

Print format for example:

2.744 : [Full GC (System) 2.744: [tenured:0k->2441k (466048K), 0.0598400 secs] 31754k->2441k (518464K), [perm:10717k->10717k (16384K)], 0.0599570 secs] [times:user=0.06 sys= 0.00, real=0.06

secs]

 

This option is enabled dynamically through the Com.sun.management.HotSpotDiagnosticMXBean API and Jconsole.

See  http://java.sun.com/developer/technicalarticles/j2se/monitoring/#Heap_Dump

-xx:-P rinttenuringdistribution

Not enabled by default

Prints the lifetime information of the object.

Printing formats such as:

[GC
Desired survivor size 4653056 bytes, new threshold (Max 32)
-Age 1:2330640 Bytes, 2330640 total
-Age 2:9520 Bytes, 2340160 total

204009k->21850k (515200K), 0.1563482 secs]

Age1 2 represents the size of the object that survived after the 1th and 2 GC.

-xx:-traceclassloading

Not enabled by default

Print class loading information to stdout. Remember loaded status.

For example:

[Loaded Java.lang.Object From/opt/taobao/install/jdk1.6.0_07/jre/lib/rt.jar]

-xx:-traceclassloadingpreorder

1.4.2 introduced, not enabled by default

Print class loading information to stdout by class reference/dependency order. Unlike traceclassloading, this option only registers loading status.

For example:

[Loading Java.lang.Object From/home/confsrv/jdk1.6.0_14/jre/lib/rt.jar]

-xx:-traceclassresolution

1.4.2 introduced, not enabled by default

Prints all static classes, constant code reference locations. For Debug.

For example:

RESOLVE Java.util.HashMap java.util.hashmap$entry hashmap.java:209

Describes the 209 rows of the HashMap class that reference a static class Java.util.hashmap$entry

-xx:-traceclassunloading

Not enabled by default

Prints the unload information for class to stdout. Remember unloaded status.

-xx:-traceloaderconstraints

Java6 introduced, not enabled by default

Prints the load policy change information for class to stdout.

 

For example:

[Adding new constraint for name:java/lang/string, loader[0]: sun/misc/launcher$ Extclassloader, loader[1]: <bootloader>]

[Setting class object in existing constraint for name: [ljava/lang/ Object; and loader Sun/misc/launcher$extclassloader]

[Updating constraint for name Org/xml/sax/inputsource, loader < Bootloader>, by setting class object]

[extending constraint for name java/lang/object by adding loader[15]: sun/ reflect/delegatingclassloader ]

 

Load policy changes are key technologies for ClassLoader isolation/namespace consistency.

For those who are interested in this, see Contraint in Http://kenwublog.com/docs/Dynamic+Class+Loading+in+the+Java+Virtual+Machine.pdf Rules chapter.

-xx:+perfsavedatatofile

Enabled by default

When the Java process is forced to terminate with Oom or crashed, a heap snapshot file is generated (what is a heap memory snapshot?). See the description at-xx:heapdumppath).

JAVA6--JVM parameter Options

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.