java命令 常用 内存 江南白衣

https://docs.oracle.com/javase/8/docs/technotes/tools/unix/java.html
http://openjdk.java.net/jeps/122

-XX:+TraceClassLoading

Enables tracing of classes as they are loaded. By default, this option is disabled and classes are not traced.

常用

https://blog.sokolenko.me/2014/11/javavm-options-production.html

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
-server
-Xms<heap size>[g|m|k] -Xmx<heap size>[g|m|k]


-XX:MaxMetaspaceSize=<metaspace size>[g|m|k]
//Sets the maximum amount of native memory that can be allocated for class metadata.

-Xmn<young size>[g|m|k]
//Sets the initial and maximum size (in bytes) of the heap for the young generation (nursery) eden+ 2 survivor space.
-Xss
//Sets the thread stack size (in bytes).
-XX:SurvivorRatio=<ratio>
// Sets the ratio between eden space size and survivor space size.

-XX:+UseConcMarkSweepGC -XX:+CMSParallelRemarkEnabled
// Enables the use of the CMS garbage collector for the old generation.

-XX:+UseCMSInitiatingOccupancyOnly -XX:CMSInitiatingOccupancyFraction=<percent>

-XX:+ScavengeBeforeFullGC -XX:+CMSScavengeBeforeRemark
//Enables GC of the young generation before each full GC.


-XX:+PrintGCDateStamps -verbose:gc -XX:+PrintGCDetails -Xloggc:"<path to log>"

-XX:+UseGCLogFileRotation -XX:NumberOfGCLogFiles=10 -XX:GCLogFileSize=100M
-Dsun.net.inetaddr.ttl=<TTL in seconds>

-XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=<path to dump>`date`.hprof
//Enables the dumping of the Java heap to a file in the current directory by using the heap profiler (HPROF) when a java.lang.OutOfMemoryError exception is thrown.

-Djava.rmi.server.hostname=<external IP>
-Dcom.sun.management.jmxremote.port=<port>
-Dcom.sun.management.jmxremote.authenticate=false
-Dcom.sun.management.jmxremote.ssl=false

内存

XX:MinHeapFreeRatio

Sets the minimum allowed percentage of free heap space (0 to 100) after a GC event. If free heap space falls below this value, then the heap will be expanded. By default, this value is set to 40%.

-XX:MaxHeapFreeRatio

Sets the maximum allowed percentage of free heap space (0 to 100) after a GC event. If free heap space expands above this value, then the heap will be shrunk

-XX:NewRatio=ratio

Sets the ratio between young and old generation sizes. By default, this option is set to 2.

-XX:NewSize=size

  • Sets the initial size (in bytes) of the heap for the young generation (nursery)
  • The -XX:NewSize option is equivalent to -Xmn.

-XX:MaxPermSize=size

Sets the maximum permanent generation space size (in bytes). This option was deprecated in JDK 8, and superseded by the -XX:MaxMetaspaceSize option.

-XX:MaxMetaspaceSize=size

Sets the maximum amount of native memory that can be allocated for class metadata. By default, the size is not limited.

1
-XX:MaxMetaspaceSize=256m

-XX:MetaspaceSize=size

Sets the size of the allocated class metadata space that will trigger a garbage collection the first time it is exceeded. This threshold for a garbage collection is increased or decreased depending on the amount of metadata used. The default size depends on the platform

-XX:CompressedClassSpaceSize=128m

江南白衣

http://calvin1978.blogcn.com

-XX:+PrintFlagsFinal

打印参数值

-XX:-UseBiasedLocking

-XX:AutoBoxCacheMax=20000