Non-standard parameters
A non-standard parameter is also called an extension parameter. Its list is as follows:
-Xint
When JVM is set to run in interpreted mode, all bytecode will be executed directly without compiling the local code.
-Xbatch
Disable background code compilation and force it to be compiled at the front end. The code can be executed only after the compilation is complete;
By default, the JVM is compiled in the background. If the compilation is not completed, the foreground code runs in interpreted mode.
-Xbootclasspath: bootclasspath
Let the JVM load the bootclass from the specified path (which can be a semicolon-separated directory, jar, or zip) to replace the Rt. Jar Of the JDK. It is generally not used unless necessary;
-Xbootclasspath/A: Path
Append all files in the specified path to the default Bootstrap path;
-Xbootclasspath/P: Path
Give JVM a higher priority over the default Bootstrap path to load all files in the specified path;
-Xcheck: JNI
Add a check to the JNI function. At this time, the JVM will verify the validity of the parameter passed to the JNI function. When illegal data is encountered in the local code, jmv will end with a fatal error; using this parameter will cause performance degradation. Please use this parameter with caution.
-Xfuture
Make JVM perform a strict format check on class files (no strict format check is performed by default JVM) to comply with the class file format specifications. We recommend that developers use this parameter.
-Xnoclassgc
Disable the GC function for class. Because it prevents memory recycle, it may cause an outofmemoryerror. Use it with caution;
-Xincgc
Enable incremental GC (disabled by default); this helps reduce the pause of the application during long GC; however, due to the possibility of concurrent execution with the application, therefore, the CPU processing capability for applications is reduced.
-Xloggc: File
Similar to the-verbose: GC function, you only need to record the status of each GC event to a file. It is best to place the file locally to avoid potential network problems.
If the command and the verbose command appear in the command line at the same time, the-xloggc prevails.
-Xmsn
Specifies the initial size of the JVM heap. The default value is 1/64 of the physical memory, and the minimum value is 1 MB. You can specify the Unit, such as K and M. If not specified, the default value is byte.
-Xmxn
Specifies the maximum value of the JVM heap. The default value is 1/4 or 1 GB of physical memory, and the minimum value is 2 MB. The unit is consistent with-XMS.
-Xprof
Tracks running programs and outputs tracing data in standard output; suitable for debugging in the development environment.
-Xrs
Reduce the JVM's use of Operating System signals (signals). This parameter is valid from 1.3.1;
Starting from jdk1.3.0, JVM allows the program to execute some code (such as shutting down the database connection pool) before closing, even if the JVM is suddenly terminated;
The JVM shutdown tool satisfies the above functions by monitoring related events on the console. More specifically, before the tool is executed, the notification first registers the console's handler, and then registers ctrl_c_event, ctrl_close_event, ctrl_logoff_event, and ctrl_shutdown_event directly return true.
However, if the JVM runs in the background in the form of a service (such as the servlet engine), it can receive the ctrl_logoff_event event, but does not need to initialize or close the program at this time. To avoid re-emergence of similar conflicts, the-xrs parameter is provided starting from jdk1.3.1. When this parameter is set, JVM will not receive handler from the console, that is, it will not monitor and process ctrl_c_event, ctrl_close_event, ctrl_logoff_event, or ctrl_shutdown_event.
-Xssn
Set the size of a single thread stack. The default value is 512 KB.
In the preceding parameters, for example-Xmsn,-xmxn ......They are all important parameters in our performance optimization;
-Xprof,-xloggc: FileAnd so on;
The jprofiler configuration mentioned in the previous section uses-Xbootclasspath/A: Path;
Non-stable parameters we mentioned earlier that the parameter list prefixed with-XX may not be robust in JVM, and sun is not recommended, in the future, it may be canceled without notice. However, many of these parameters are useful to us, for example, we often see-XX: permsize,-XX: maxpermsize, and so on;
Next we will discuss in Java hotspot VM-XX:The configurable parameter list;
These parameters can be loosely aggregated into three types:
Behavior parameters(Behavioral options): Used to change some basic JVM behaviors;
Performance Tuning(Performance Tuning): used for JVM performance tuning;
Debugging Parameters(Debugging options): generally used to open JVM parameters such as tracing, printing, and output, and display more detailed JVM information;
Since Sun's official documents have very few descriptions of each parameter (most of them only have one sentence), and most of them involve OS-level things, it is difficult to clearly describe them, therefore, the following are some configuration items that may be used in development. To view the list of all parameters, click hotspot VM specific options. view the original text;
First, we will introduceBehavior parameters:
Parameters and Their default values |
Description |
-XX:-disableexplicitgc |
Disable calling system. GC (). However, the jvm gc is still valid. |
-XX: + maxfdlimit |
Maximum number of file descriptors |
-XX: + scavengebeforefullgc |
The new generation GC takes precedence over full GC. |
-XX: + usegcoverheadlimit |
Limit the time ratio of JVM to GC before oom is thrown. |
-XX:-useconcmarksweepgc |
GC for the old generation using the concurrent tag switching algorithm |
-XX:-useparallelgc |
Enable parallel GC |
-XX:-useparalleloldgc |
Enable parallel for full GC. This option is automatically enabled when-XX:-useparallelgc is enabled. |
-XX:-useserialgc |
Enable serial GC |
-XX: + usethreadpriorities |
Enable local thread priority |
The three parameters in the above table represent the three methods for GC execution in JVM, that is
Serial, parallel, and concurrent;
Serial
(Serialgc)It is the default GC method of JVM and is generally applicable to small applications and single processors. The algorithm is relatively simple and the GC efficiency is high, but it may bring a pause to the application;
Parallel
(Parallelgc)It means that the GC operation has no impact on the application program running, and the GC and app threads are concurrently executed, so that the operation of the app can be minimized;
Concurrency
(Concmarksweepgc)It refers to the concurrent execution of GC by multiple threads. It is generally applicable to multi-processor systems and can improve the GC efficiency. However, the algorithm is complicated and the system consumes a lot;
Performance TuningParameter List:
Parameters and Their default values |
Description |
-XX: largepagesizeinbytes = 4 m |
Set the large page size for Java heap |
-XX: maxheapfreeratio = 70 |
The largest percentage of free space in the Java heap after GC |
-XX: maxnewsize = size |
Maximum memory occupied by the new pair |
-XX: maxpermsize = 64 m |
Maximum memory usage of old generation objects |
-XX: minheapfreeratio = 40 |
Minimum Percentage of free space in the Java heap after GC |
-XX: newratio = 2 |
Ratio of memory capacity of the new generation to memory capacity of the old generation |
-XX: newsize = 2.125 m |
Default memory usage when new generation objects are generated |
-XX: reservedcodecachesize = 32 m |
Reserve the memory used by the code |
-XX: thread stacksize = 512 |
Sets the thread stack size. If it is 0, the default value is used. |
-XX: + uselargepages |
Use large page memory |
We basically use the above attributes in daily performance tuning;
Debugging ParametersList:
Parameters and Their default values |
Description |
-XX:-citime |
Print the time consumed by JIT compilation |
-XX: errorfile =./hs_err_pid <pid>. Log |
Save error logs or data to a file |
-XX:-extendeddtraceprobes |
Enable the dtrace probe unique to Solaris |
-XX: heapdumppath =./java_pid <pid>. hprof |
Specifies the path or file name for exporting heap Information |
-XX:-heapdumponoutofmemoryerror |
When oom is first encountered, export the relevant information in the heap. |
-XX: |
Run the custom command after a fatal error occurs. |
-XX: onoutofmemoryerror = "<cmd ARGs>; <cmd ARGs>" |
Execute custom commands When oom is first encountered |
-XX:-printclasshistogram |
Print the column information of the class instance after Ctrl-break, which is the same as that of jmap-histo. |
-XX:-printconcurrentlocks |
Print the information about the concurrent lock after encountering Ctrl-break, which is the same as the jstack-l function. |
-XX:-printcommandlineflags |
Print the mark that appears in the command line |
-XX:-printcompilation |
Print related information when a method is compiled. |
-XX:-printgc |
Print related information during each GC |
-XX:-printgc details |
Print detailed information for each GC |
-XX:-printgctimestamps |
Print the timestamp of each GC |
-XX:-traceclassloading |
Tracking class loading information |
-XX:-traceclassloadingpreorder |
Tracks the loading information of all referenced classes. |
-XX:-traceclassresolution |
Tracking constant pool |
-XX:-traceclassunloading |
Unload information of the trace class |
-XX:-traceloaderconstraints |
Tracking Information about the constraints of the Class Loader |
External tracing tools (such as jprofiler...) cannot be used when the system encounters a problem ......) In this case, the above parameters will play a major role, such as dump heap information, printing concurrent locks ......
Detailed description of JVM startup parameters (for conversion)