Run java -help to see the basic format and options
-help / -?: output help information
-version: output version information
-classpath / -cp: class search path for directories and
...Other uncommon parameters
Non-standard options (the
Compile mode options.
-Xint: interpreted mode execution only
-Xcomp: opposite of
-Xint, fully compile on first use
-Xmixed: (default) mixed mode
Examples of the three modes of JVM operation.
Abbreviated options for advanced options (
-Xms: Sets the minimum and initial size of the heap. This parameter is equal to
-Xmx: Sets the maximum size of the heap,
-Xmsis usually set to the same value as
-Xmx. This parameter is equal to
-Xmn: Sets the initial and maximum size of the young Generation heap. This parameter is equal to setting both
-Xss: Sets the individual thread stack size, typically
512k ~ 1024k. This parameter is equal to the same as
-XX:ThreadStackSize. The default values are as follows: (depends on the platform)
- Linux/ARM (32-bit): 320 KB
- Linux/i386 (32-bit): 320 KB
- Linux/x64 (64-bit): 1024 KB
- OS X (64-bit): 1024 KB
- Oracle Solaris/i386 (32-bit): 320 KB
- Oracle Solaris/x64 (64-bit): 1024 KB
- Windows: determined by virtual memory
Advanced options (
According to the official classification, there are four types as follows
- Advanced Runtime Options
- Advanced JIT Compiler Options
- Advanced Serviceability Options
- Advanced Garbage Collection Option
According to the classification of the way to set parameters, there are two types as follows
KVset value type:
- Capacity type (no
Bsuffix is allowed)
- Numeric unitless representation
-XX:+PrintCommandLineFlags: Enables printing of JVM configuration on the command line, such as heap space size and the selected garbage collector. Disabled by default.
-XX:MetaspaceSize=size: Sets the size of the metadata space that will trigger garbage collection when it is exceeded for the first time. This threshold for garbage collection increases or decreases depending on the amount of metadata in use. The default size depends on the platform.
-XX:MaxMetaspaceSize=size: Sets the maximum amount of native memory for metadata. By default, there is no limit on the size. The amount of application metadata depends on the application itself, other running applications, and the amount of memory available in the system.
-XX:SurvivorRatio=ratio: Sets the ratio between the size of
Edenspace and the size of
Survivorspace. The default value is 8, i.e.
-Xms -Xmx: Usually set to the same value
-Xmx: Young Generation heap region is used for new objects. This area performs
GCmore often than other areas. If the young generation is too small, then
Young GCwill be executed frequently. If it is too large, then only
Full GCwill be executed, which may take a long time to complete.
Oraclerecommends keeping the young generation heap size between half and a quarter of the overall heap size
-Xss: generally set to
-XX:+PrintCommandLineFlags: recommended to enable
-XX:MetaspaceSize=size -XX:MaxMetaspaceSize=size: Generally
-XX:SurvivorRatio=ratio: default value is 8, recommended to add
It is recommended to lower the value of the above startup parameters when the virtual machine is running low on resources,for example.