server
Dual-core, four cores; 16G memory
[root@alish2-cassandra-01 ~]# cat /proc/cpuinfo | grep "cpu cores"
cpu cores : 2
cpu cores : 2
Brief formula
Priority response time of concurrent collector, mainly to ensure the system's response time, reduce the pause time garbage collection. Suitable for application servers, telecommunications and other fields.
-
ParNew collector
ParNew collector is multi-threaded version of the Serial collectors, many of the virtual machines running under Server mode of choice for the new generation of collectors, in addition to Serial, only it can work with CMS collector.
-
CMS collector
CMS, the full name of Concurrent Low Pause Collector, a new gc algorithm were introduced in later versions jdk1.4, has been further improved in jdk5 and jdk6 in its main demand for the scene is the importance of response time is greater than the throughput requirements , able to withstand the garbage collection thread and application threads share processor resources, and application objects are more long-lifecycle applications exist. CMS is used for the recovery of tenured generation, which is the old generation of recycling, the goal is to minimize the use of suspended time, reduce the risk of FullGC occur, use and application thread concurrent garbage collection thread to mark remove the old generation.
CMS is not without pause, but with a short pause twice to replace long pause serial tags to organize algorithm, and its collection cycle like this:
initial mark (CMS-initial-mark) - > concurrent mark (CMS-concurrent-mark) -> relabeled (CMS-remark) -> concurrent Clear (CMS-concurrent-sweep) - > concurrent reset state waiting for the next trigger CMS (CMS-concurrent-reset)
which 1,3 two steps are required to suspend all application threads. The first pause start mark live objects from the root objects, this phase is called the initial mark; the second is a pause after the concurrent mark, suspend all application threads, subject to re-mark the concurrent marking phase missing (concurrent mark the end of the stage updated object state leads). The first pause will be relatively short, usually second pause will be longer, and the remark at this stage in parallel mark.
The concurrent mark, concurrent cleared, reset the stage complicated by so-called concurrency, refers to one or more of the garbage collection thread and application threads running concurrently, the garbage collector thread does not suspend the application, if you have more than one processing device, then the thread will run concurrent collection and application threads on different processors, it is clear that such expenses will reduce throughput applications. Parallel Remark stage refers to the suspension of all applications, to start a number of parallel garbage collection process off, and now the application thread is suspended.
official
($TOMCAT_HOME/bin/catalina.sh)
export JAVA_OPTS="-server -Xmx10240m -Xms10240m -Xmn3840m -XX:PermSize=256m
-XX:MaxPermSize=256m -Denv=denalicnprod
-XX:SurvivorRatio=8 -XX:PretenureSizeThreshold=1048576
-XX:+DisableExplicitGC
-XX:+UseParNewGC -XX:ParallelGCThreads=10
-XX:+UseConcMarkSweepGC -XX:+CMSParallelRemarkEnabled
-XX:+CMSScavengeBeforeRemark -XX:ParallelCMSThreads=10
-XX:CMSInitiatingOccupancyFraction=70
-XX:+UseCMSInitiatingOccupancyOnly
-XX:+UseCMSCompactAtFullCollection -XX:CMSFullGCsBeforeCompaction=0
-XX:+CMSPermGenSweepingEnabled -XX:+CMSClassUnloadingEnabled
-XX:+UseFastAccessorMethods
-XX:LargePageSizeInBytes=128M
-XX:SoftRefLRUPolicyMSPerMB=0
-XX:+PrintGCDetails -XX:+PrintGCTimeStamps -XX:+PrintHeapAtGC
-XX:+PrintGCApplicationStoppedTime
-XX:+PrintGCDateStamps -Xloggc:gc.log -verbose:gc"
Analytic formula
Participation number | meaning |
---|---|
-server | Be sure to as the first parameter to enable server versions of the JDK, good performance when multiple CPU |
-Xms | java Heap initial size. The default is the physical memory of 1/64. This value can be set the same -Xmx, each JVM to avoid reallocate memory garbage collection completes. |
-Xmx | java heap maximum. Recommendations are set to 80 percent of physical memory. Not exceed the physical memory. |
-Xmn | The size of the young generation is provided, generally set Xmx 2/8 ~ 3/8, equivalent to -XX: NewSize and -XX: MaxNewSize. |
-XX:PermSize | The initial size of the permanent memory storage area setting defaults 64M |
-XX:MaxPermSize | The maximum size of the memory of the permanent preservation area setting, default is 64M |
-Denv | Specify which project run tomcat |
-XX:SurvivorRatio | The ratio of the size of the region Eden Survivor region, is set to 8, the ratio of the two regions with a Survivor Eden zone is 2: 8, a Survivor young generation area 1/10 of the total |
-XX:PretenureSizeThreshold | Promotion object size of the old generation. The default is 0, for example, is set to 1048576 (1M), and more than 1M object will not eden zone distribution, directly into the old generation. |
-XX:+DisableExplicitGC | Close System.gc () |
-XX:+UseParNewGC | Set concurrent collection on behalf of the young. CMS can be collected and used simultaneously. |
-XX:ParallelGCThreads | |
-XX:+UseConcMarkSweepGC | Set old took the concurrent collection. After testing this configuration, -XX: NewRatio = 4 configuration fails. Therefore, when the size of the young generation is preferably provided with -Xmn. |
-XX:+CMSParallelRemarkEnabled | Open parallel remark |
-XX:+CMSScavengeBeforeRemark | This parameter is quite important, it means once youngGC before executing the CMS remark, which can effectively reduce the time remark |
-XX:ParallelCMSThreads | The number of recovery threads CMS is enabled by default (ParallelGCThreads + 3) / 4), if you need to explicitly set by -XX: set ParallelCMSThreads = 20, which ParallelGCThreads is the number of parallel threads to collect the young generation |
-XX:CMSInitiatingOccupancyFraction | After using cms 70% as CMS began collecting garbage |
-XX:+UseCMSInitiatingOccupancyOnly | Use manually define the initial definition of CMS began collecting |
-XX:+UseCMSCompactAtFullCollection | Open compression of the old generation. It may affect performance, but can eliminate the memory fragmentation. |
-XX:CMSFullGCsBeforeCompaction | Since the memory space concurrent collector does not compress, organize, it will have a "debris" after a period of operation, so as to reduce operating efficiency. This parameter is set to run later times FullGC memory space compression, finishing. |
-XX:+CMSPermGenSweepingEnabled | In order to avoid full gc Perm region full cause, it is recommended to open CMS recycling options Perm region |
-XX:+CMSClassUnloadingEnabled | |
-XX:+UseFastAccessorMethods | Fast optimization of the original type |
-XX:LargePageSizeInBytes | Memory page size can not be set too high, it will affect the size of Perm |
-XX:SoftRefLRUPolicyMSPerMB | "Soft references" of the object to be accessed after the last viable 0 milliseconds (default is 1 second). |
-XX:+PrintGCDetails | Record Detail GC runtime data, including the size of the memory for the new object is generated and time-consuming |
-XX:+PrintGCTimeStamps | Print garbage collection timestamp |
-XX:+PrintHeapAtGC | For more information on the stack before and after printing GC |
-XX:+PrintGCApplicationStoppedTime | Program suspended during printing garbage collection time can be mixed with the above |
-XX:+PrintGCDateStamps | 之前打印gc日志的时候使用是:-XX:+PrintGCTimeStamps,这个选项记录的是jvm启动时间为起点的相对时间,可读性较差,不利于定位问题,使用PrintGCDateStamps记录的是系统时间,更humanreadable |
-Xloggc | 与上面几个配合使用,把相关日志信息记录到文件以便分析 |
-verbose:gc | 记录 GC 运行以及运行时间,一般用来查看 GC 是否是应用的瓶颈 |