Java startup parameters are divided into three categories;
The first is the standard parameter (-), all JVM implementations must implement the functions of these parameters, and backward compatibility;
The second is the non-standard parameter (- x), the default JVM implements the functions of these parameters, but does not guarantee that all JVM implementations are satisfied, and does not guarantee backward compatibility;
The third is the non-stable parameter (-XX), such parameters of each JVM implementation will be different, in the future may be canceled at any time, need to use cautiously;
first, the standard parametersMore useful in:
- Verbose-verbose:class
Outputs information about the JVM loading classes that can be diagnosed when the JVM reports that a class or class violation is not found.
-verbose:gc
Outputs the correlation of each GC.
-verbose:jni
The output native method invocation is typically used to diagnose JNI invocation error messages.
- -help : output java standard parameter list and its description.
- -X: outputs a non-standard parameter list and its description.
Sets the system attribute name/value pair, and the application running on top of this JVM can get the value of the System.getproperty ("property"). If there are spaces in value, you need to enclose the value in double quotation marks, such as-dname= "space string". This parameter is typically used to set system-level global variable values, such as a configuration file path, so that the property is accessible anywhere in the program.
- -client: set the JVM to use the client mode, characterized by faster start-up, but inefficient runtime performance and memory management, typically used for client application or PC application development and debugging.
- -server: Set the JVM to make the server mode, characterized by slow boot speed, but run-time performance and memory management is very efficient, suitable for production environments. This mode is enabled by default in a JDK environment with 64-bit capability, and the-client parameter is ignored.
Second, non-standard parametersAlso known as extended parameters, the most commonly used is
-XMS512m sets the JVM initial memory to 512m. This value can be set to the same as-xmx to avoid the JVM reallocating memory after each garbage collection completes.
-Xmx512m set JVM maximum available memory is 512M.
-xmn200m sets the young generation size to 200M. The entire heap size = younger generation size + old generation size + persistent generation size. The permanent average fixed size is 64m, so increasing the younger generation will reduce the size of older generations. This value has a large impact on system performance, and Sun's official recommendation is 3/8 for the entire heap.
-XSS128k:
Sets the stack size for each thread. After JDK5.0, each thread has a stack size of 1M, before each thread has a stack size of 256K. Adjusts according to the size of the memory required by the application's thread. In the same physical memory, reducing this value can generate more threads. However, the operating system of the number of threads within a process is still limited, can not be generated indefinitely, the empirical value of 3000~5000 around.
-xloggc:file
Similar to the-VERBOSE:GC feature, just log the correlation of each GC event to a file, preferably locally, to avoid potential problems with the network.
If the verbose command appears on the command line at the same time, the-XLOGGC will prevail.
-xprof
Keep track of running programs and trace data in standard output, suitable for development environment debugging.
The list of parameters prefixed with-XX may not be robust in the JVM, Sun is not recommended, and may be canceled without notice, but many of these parameters are useful to us, such as the-xx:permsize and-xx that we often see: MaxPermSize and so on;
First, let's introduce the behavior parameters :
Parameters and their default values |
Describe |
-xx:-disableexplicitgc |
Disable calling System.GC (), but the JVM's GC is still valid |
-xx:+maxfdlimit |
Limit the number of file descriptors to maximize |
-xx:+scavengebeforefullgc |
The new generation GC takes precedence over full GC execution |
-xx:+usegcoverheadlimit |
Limit the amount of time the JVM spends on GC before throwing an Oom |
-XX:-USECONCMARKSWEEPGC |
using concurrent tag switching algorithm for GC in Laosheng generation |
-XX:-USEPARALLELGC |
Enable parallel GC |
-xx:-useparalleloldgc |
Enable parallelism on the full GC, which is automatically enabled when-XX:-USEPARALLELGC is enabled |
-XX:-USESERIALGC |
Enable serial GC |
-xx:+usethreadpriorities |
Enable local thread Priority |
The three parameters of the blackbody in the table above represent three ways that the GC executes in the JVM, namely serial, parallel, concurrency ;
Serial (SERIALGC) is the default GC mode of the JVM, which is generally suitable for small applications and single processors, the algorithm is simple and the GC is more efficient, but it may bring pause to the application.
Parallel (PARALLELGC) refers to the GC runtime, no impact on the application run, GC and app both threads are executing concurrently, so as to minimize the impact of the app operation;
Concurrency (CONCMARKSWEEPGC) is a multi-thread concurrent execution GC, generally applicable to multiprocessor systems, can improve the efficiency of GC, but the algorithm is complex, the system consumes large;
Performance Tuning parameter list:
Parameters and their default values |
Describe |
-xx:largepagesizeinbytes=4m |
Set a large page size for the Java heap |
-xx:maxheapfreeratio=70 |
Maximum percentage of idle amount in the Java heap after GC |
-xx:maxnewsize=size |
the maximum amount of memory that a new build object can occupy |
-xx:maxpermsize=64m |
the maximum amount of memory that a Laosheng object can occupy |
-xx:minheapfreeratio=40 |
Minimum percentage of idle amount in the Java heap after GC |
-xx:newratio=2 |
The ratio of the new generation memory capacity to the Laosheng memory capacity |
-xx:newsize=2.125m |
default value of memory used by Cenozoic object generation |
-xx:reservedcodecachesize=32m |
Reserve the amount of memory your code consumes |
-xx:threadstacksize=512 |
Set the thread stack size to use the system default value if 0 |
-xx:+uselargepages |
Use large page memory |
In the daily performance tuning we will basically use the above properties of the blackbody;
Debug Parameter list:
Parameters and their default values |
Describe |
-xx:-citime |
When the print consumption is JIT-compiled |
-xx:errorfile=./hs_err_pid<pid>.log |
Save the error log or data to a file |
-xx:-extendeddtraceprobes |
To open a Solaris-specific dtrace probe |
-xx:heapdumppath=./java_pid<pid>.hprof |
specifies the path or file name when the heap information is exported |
-xx:-heapdumponoutofmemoryerror |
Export the information in this heap when an oom is first encountered |
-xx:onerror= "<cmd args>;<cmd args>" |
Run the custom command after a fatal error occurs |
-xx:onoutofmemoryerror= "<cmd args>;<cmd args>" |
Execute a custom command when an oom is first encountered |
-xx:-P Rintclasshistogram |
Print the column information of the class instance after encountering Ctrl-break, same as the Jmap-histo function |
-xx:-P rintconcurrentlocks |
Print concurrency lock information after encountering Ctrl-break, same as jstack-l function |
-xx:-P Rintcommandlineflags |
Print markup that appears on the command line |
-xx:-P rintcompilation |
When a method is compiled, the relevant information is printed |
-xx:-P RINTGC |
Print related information each time the GC |
-xx:-P RINTGC Details |
Print Details per GC |
-xx:-P Rintgctimestamps |
Print timestamp for each GC |
-xx:-traceclassloading |
Tracking load information for a class |
-xx:-traceclassloadingpreorder |
Trace load information for all classes referenced to |
-xx:-traceclassresolution |
TRACE Constant Pool |
-xx:-traceclassunloading |
Tracking uninstall information for a class |
-xx:-traceloaderconstraints |
Tracking information about class loader constraints |
Java Virtual machine startup parameter classification detailed