JVM practice common configuration

A, JVM common base configuration

Ø - Xmn : Cenozoic memory limit
Ø - the Xms : Initial entire heap memory allocation area size
Ø - Xmx : the entire heap memory allocation area of maximum limit recommended - Xms and - Xmx setting is equivalent to the size, to avoid the consumption dynamic recovery resources
Ø - XX: MetaspaceSize (JDK1.8 support ) corresponding JDK1.8 following - XX: PermSize = , identifying a minimum element space ( Permanent Generation / method area ) Size
Ø - XX: MaxMetaspaceSize (JDK1.8 support ) corresponding JDK1.8 less of - XX: MaxPermSize , identifying the maximum element space ( Permanent Generation / method area ) Size
Ø -XX: + HeapDumpOnOutOfMemoryError when there OOM , the print heap dump dump file
Ø - XX: HeapDumpPath = specified heap dump dump file storage path
Ø - Dfile.encoding = UTF-8 set the system file encoding format is UTF-8
Ø -XX: + PrintGCDetails output a GC detailed log recovery
Ø -XX: + PrintGCDateStamps output GC recovery detailed time stamp record for the system
Ø - Xloggc : / Export / Logs / JVM /gc.log  recording GC recovery log file path
Ø -XX: + PrintGCCause (JDK1.8 support ) to print out the GC reasons for recycling
Ø -XX: + DisableExplicitGC : manual configuration prohibit the use of an external call System.gc to trigger garbage collection
 

Two, JVM used to optimize the configuration

Ø -XX: + UseParNewGC manually specify the new generation of multi-threaded collection device
Ø -XX: + UseConcMarkSweepGC : manually specify the year using the old CMS collection device
Ø -XX: + UseCMSInitiatingOccupancyOnly without this option, if you need to perform in accordance with the decision costing the CMS gc , With this option, when the old generation space usage reaches 92% of the time will be the unconditional implementation of Full GC
Ø -XX: + CMSClassUnloadingEnabled : manually specify CMS collector generation of non-persistent heap area for recycling, recovery is not the default permanent substituting
Ø - XX: CMSInitiatingOccupancyFraction = 80: manually specify when old's used space reaches 80% , the trigger old's recovery ( default 92 %)
Ø - XX: CMSInitiatingPermOccupancyFraction = 80: manually specify when the permanent generation of used space of 80% , the trigger generation of permanent recycling ( default 92%)
Ø - Xnoclassgc   : Close CLASS garbage collection function, the default 20 Fenzhong this class is not in use, the virtual machine to uninstall this class. Again re-use load
Ø -XX: + UseCMSCompactAtFullCollection : making Full GC of memory for compression, JDK1.6 before do not need to configure the default open
Ø - XX: CMSFullGCsBeforeCompaction = 2: with -XX: + UseCMSCompactAtFullCollection associated with the use of identity through how many times per Full GC is triggered once the memory is compressed, the default is 0 times
 
 

Three, JVM configuration tuning - Common Case

During tuning configuration M, it is an ongoing optimization process, and no silver bullet. Follow requires a long time to time Xc + PrintGcDetails
log information Xc + PrintGcDateStamps configured to generate, combined UMP, MDC data monitoring platform, arranged in the system to optimize tuning M

1, Yong GO perform time-consuming tuning configuration

The default upgrade parallel concurrent GC GC
> -XX: + UseParNewGC: manually specify the new generation multithreading collector
tune the new generation Eden, s0, each partition ratio S1
> -XX: = SurvivorRatio. 6: Eden region Survivor0, Survivor1 region size ratio is recommended to 6, the default is 8, Eden: S0S1 = 611
to adjust the new generation of recovering viable Age
> -XX: Max Threshold = 5: manually set the live objects in the new generation of age (survival times), default 15 secondary

2, Yong Gc purple performing a frequency, tuning configuration

Adjust the new generation, heap area, Yuan spatial size
> -Xmn: the new generation of memory upper limit
> -Xms: size of the initial heap memory allocation of the entire area
> -Xmx: maximum heap memory allocation limit throughout the area, and recommended ms Xmx provided with the same size, to avoid the consumption of resources dynamically recovered
> -XX: metaspace size = (DK18 support), corresponding to the following DK18 XX: PermSize =, identifying a minimum element space (permanent Generation / region method) size
> -XX: MaxMetaspace size (DK .8 support), corresponding to the following DK18 XX: MaxPermSize, identifying the maximum element space (permanent Generation / region method) size

3, Full GC perform time-consuming tuning configuration

The upgrade is made parallel default Gc GC
> -XX: + the Use ConcMarkSweepGC: manually specify the old CMS's use of concurrent collector
Note: Due to G1 collector is not used in actual combat, they will not do introduce
open fullA compression, and compression reduce Full go number of pros and cons
> -XX: + UseCMSCompactAtFullCollection: memory compression during Fu Shan GC, open full GC compression
> -XX: CMSFullGCsBeforeCompaction = 2: with X + se CMscompactAt FullCollection associated with using the identification number after each
time the trigger on FuGC a memory for compression, the default is 0 times

4, no memory Full GO continues to grow, TP99 increased

Open when using a certain amount of years old, forced triggering Fu | Gc Recycling
> -XX: + UseCMSinitiatingoccupancyon: without this option, if you need to perform CMs gC calculated decision based on cost, plus the
option, when the old generation space usage unconditional execution Fu reached 92% | GC
> -XX: CMSInitiating Occupancy Fraction = 80: when manually specify when old's used space reaches 80%, triggering years old and 92% recovery of default)
opened F called GC-generation permanent recovery of ( pros and cons)
> -XX: + CMSClassUnloading Enabled: manually specify CMS collector permanent non-generation heap area for recycling, generation of permanent default is not recovered
> -XX: CMSInitiatingoccupancy Fraction = 80: manually specify when the permanent generation of space has been used 80 %, the generation of the trigger permanent collection (default 92%)

 
发布了49 篇原创文章 · 获赞 46 · 访问量 33万+

Guess you like

Origin blog.csdn.net/weixin_42343424/article/details/103983574