Basic Format
Run java -help to see the basic format and options
Standard options
-help / -?
: output help information-version
: output version information-classpath / -cp
: class search path for directories andzip/jar
files...
Other uncommon parameters
Non-standard options (the X
parameter)
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 (xx
parameters)
-Xms
: Sets the minimum and initial size of the heap. This parameter is equal to-XX:InitialHeapSize
-Xmx
: Sets the maximum size of the heap,-Xms
is usually set to the same value as-Xmx
. This parameter is equal to-XX:MaxHeapSize
-Xmn
: Sets the initial and maximum size of the young Generation heap. This parameter is equal to setting both-XX:NewSize
and-XX:MaxNewSize
.-Xss
: Sets the individual thread stack size, typically512k ~ 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 (XX
parameters)
Classification methods
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
Boolean
type.
-XX:+
means on-XX:-
means off
KV
set value type:-XX:Key=Value
- Capacity type (no
B
suffix is allowed)k
orK
forKB
m
orM
forMB
g
orG
forGB
- Numeric unitless representation
B
- Numeric
- Size
- Proportional
Common settings
-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 ofEden
space and the size ofSurvivor
space. The default value is 8, i.e.Eden:S0:S1
= 8:1:1
-Xms -Xmx
: Usually set to the same value-Xmx
: Young Generation heap region is used for new objects. This area performsGC
more often than other areas. If the young generation is too small, thenYoung GC
will be executed frequently. If it is too large, then onlyFull GC
will be executed, which may take a long time to complete.Oracle
recommends keeping the young generation heap size between half and a quarter of the overall heap size-Xss
: generally set to1M
-XX:+PrintCommandLineFlags
: recommended to enable-XX:MetaspaceSize=size -XX:MaxMetaspaceSize=size
: Generally256M
is sufficient-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.
|
|