1. Adjust the maximum heap memory
-Xmx 8192m
2. Adjust the minimum heap
-Xmx 8192m
3. Set the virtual machine garbage collection
-XX: + UseG1GC
4. garbage collected log information
-Xloggc: / D: gc.log
5.OOM automatically generate exception dump file after
-XX: + HeapDumpOnOutOfMemoryError / -XX: HeapDumpOnCtrlBreak [ctrl + Break]
6. Review all jvm default parameters
-XX: + PrintFlagsFianl
jstat statistics class loading, run out of memory, garbage collection, the JIT compilation data
jstat [option jvmid [interval count]
] queries the total query every 200 milliseconds 10 times
jstat $ (jcmd | grep SJJ | awk '{print $ 1}' ) 20010
jstat -gcutil
Solution:
echo 0 | sudo TEE / proc / SYS / Kernel / yama / ptrace_scope
Gc information every 10 line display, the interval length of one second
jstat -gc -h10 jvmid 1000
jmap: java memory analysis tool
jmap cmd jvmid
如:jmap -dump:format=b,file=any.bin jvmid
jstack Java stack trace tool
generates a snapshot of the current thread, the current thread positioning pause reason: deadlock, infinite loop, external requests for too long, etc.
jinfo 实时查看jvm各项参数
查看CMSInitiatingOccupancyFraction 信息
jinfo -flag CMSInitiatingOccupancyFraction jvmid
查看System.properties()信息
jinfo -sysprops