JVM basic parameter settings

  # JVM基本参数设置

1. General arrangement

  1. -XX:PretenureSizeThreshold=1m : Large objects are directly allocated in the old generation. This parameter is only valid for the Serial and ParNew collectors
  2. -XX:MaxTenuringThreshold=15 : The dynamic age exceeds 15 times and enters the old age. If it is equal to 0, it goes directly to the old age
  3. -Xms20m : Set the maximum memory of the heap
  4. -Xmx20m : Set the heap memory size
  5. -Xmn10m : Set the memory size of the new generation
  6. -XX:G1HeapRegionSize : the size of each Region of the G1 collector
  7. -XX:SurvivorRatio=8 : Set the ratio of an eden and a suvivor
  8. -XX:+PrintTenuringDistribution : JVM prints out the age distribution of objects in the surviving area each time the Cenozoic GC

2.G1 configuration

  1. -XX:+UseG1GC : Use G1 garbage collector
  2. -XX:MaxGCPauseMillis=N : set the maximum pause time
  3. -XX:G1HeapRegionSize=N : Set the size of each region, the range is 1-32m, which is a power of 2
  4. -XX:ParallelGCThreads=8 : Set the number of G1 GC recycling threads
  5. -XX:ConcGCThreads : Concurrent marking stage, set the number of gc worker threads
  6. -XX:InitiatingHeapOccupancyPercent : The default is 45%. This percentage is related to the start of the concurrent cycle. When the space percentage reaches this value, the concurrent cycle will be started. If FullGC often occurs, you can lower this value. Early recovery can reduce the trigger of FullGC, but if it is too low, the concurrent phase will be more frequent and reduce the throughput of the application.
  7. .-XX:G1MixedGCLiveThresholdPercent : The occupancy threshold of the old region in the mixed garbage collection cycle. The default value is 85, which means that if the live objects in an Old Region are greater than 85% of the region size, the region will not be recycled. Join Cset. Otherwise, putting 85% of the surviving objects in another Region during recycling, the gains outweigh the losses.
  8. -XX:G1MixedGCCountTarget = 8 : Set the number of mixed collections after the marking period is completed. The default is 8 times. If a single collection of CSet + young generation time far exceeds the maximum pause time, multiple mixed GCs will be triggered to collect part of the CSet each time to achieve the maximum pause time.
  9. -XX:G1HeapWastePercent=5 : Set the percentage of wasted heap memory. When the recyclable percentage is less than the waste percentage, the JVM will not start mixed garbage collection. That is, after concurrent marking, mixed GC will not necessarily be triggered.

3. CMS configuration

  1. -XX:+UseConcMarkSweepGC : Use cms garbage collector
  2. -XX:CMSInitiatingOccu-pancyFraction : the threshold triggered by the cms collector

4.Paraller configuration

  1. -XX:+UseAdaptiveSizePolicy : adaptive
  2. -XX:MaxGCPauseMillis=100 : The parameter that controls the maximum garbage collection pause time.
  3. -XX:GCTimeRatio=19 : directly set the throughput parameter.
  4. -XX:+UseParallelOldGC:使用parallel scavenge + parallel old

5.GC log

  1. -XX:+PrintGCApplicationStoppedTime : print the time of user thread stw
  2. -XX:+PrintGCDetails : Print GC log details
  3. XX:+PrintGCDateStamps outputs the GC timestamp (in the form of date, such as 2013-05-04T21:53:59.234+0800)
  4. -XX:+PrintSafepointStatistics + -XX:PrintSafepointStatisticsCount=1 : View the safepoint log

Guess you like

Origin blog.csdn.net/weixin_44981707/article/details/112686653