* -XX:+UseParallelGC : 和传统的新生代GC一样,只是可以进行并行标记处理。 可通过-XX:ParallelGCThreads指定并发线程数,默认值:-XX:ParallelGCThreads =<#cpus < 8 ? #cpus : 3 + ((5 * #cpus) / 8) >
The new parallel garbage collector is similar to the young generation collector in the default garbage collector but uses multiple threads to do the collection. By default on a host with N CPUs, the parallel garbage collector uses N garbage collector threads in the collection. The number of garbage collector threads can be controlled with a command line option (see below). On a host with a single CPU the default garbage collector is used even if the parallel garbage collector has been requested. On a host with 2 cpus the Parallel garbage collector generally performs as well as the default garbage collector and a reduction in the young generation garbage collector pause times can be expected on hosts with more than 2 cpus.
* XX:+UseParNewGC: 和UseParallelGC类似,也是并行处理,但实现技术还是不同,据说在新生代的火车模型上有更少的停顿时间。
* -XX:+ DisableExplicitGC : 禁用system.gc()调用
Don't call System.gc(). The system will make the determination of when it's appropriate to do garbage collection and generally has the information necessary to do a much better job of initiating a garbage collection. If you are having problems with the garbage collection (pause times or frequency), consider adjusting the size of the generations.
* -XX:+AggressiveOpts 加快编译
* -XX:+UseBiasedLocking 锁机制的性能改善。
* -Xss=256k
-Xss 是线程栈的大小, 这个参数需要严格的测试, 一般小的应用, 如果栈不是很深, 应该是128k够用的, 不过,我们的应用调用深度比较大, 还需要做详细的测试。 这个选项对性能的影响比较大。 建议使用256K的大小.
文章:http://www.iteye.com/topic/473874
-XX:+CMSParallelRemarkEnabled : 在和UseParNewGC一起使用的情况下,尽量减少mark的时间
-XX:+UseConcMarkSweepGC : 指定在Old Generation使用concurrent gc
-XX:+UseCMSCompactAtFullCollection : 在使用concurrent gc的情况下,防止memory fragmention
-XX:CMSInitiatingOccupancyFraction=n : 指示在old generation在使用了n%的后,触发cms gc
-XX:+UseCMSInitiatingOccupancyOnly : 指示只有在old generation在使用了初始化的比例后启动cms gc
公司参数列表记录:
-server -Xmx2g -Xms2g -Xmn256m -XX:PermSize=128m -Xss256k -XX:+DisableExplicitGC -XX:+UseConcMarkSweepGC -XX:+CMSParallelRemarkEnabled -XX:+UseCMSCompactAtFullCollection -XX:LargePageSizeInBytes=128m -XX:+UseFastAccessorMethods -XX:+UseCMSInitiatingOccupancyOnly -XX:CMSInitiatingOccupancyFraction=70
http://www.oracle.com/technetwork/java/javase/tech/g1-intro-jsp-135488.html
jdk 1.6.14中首次引入了G1.
G1的特点描述:
-XX:+G1YoungGenSize=512m
(for a 512 megabyte young generation) 这里搞不明白,是G1重新划分新生代?还是仅仅只是在GC中划分的区域。 -XX:SurvivorRatio=6 调整surivor regoins的大小
-XX:+G1ParallelRSetUpdatingEnabled -XX:+G1ParallelRSetScanningEnabled 不知道干吗的,先记着
49.414: [GC [PSYoungGen: 10480K->0K(524160K)] 11272K->792K(2097024K), 0.0002270 secs] [Times: user=0.00 sys=0.00, real=0.00 secs]
三种垃圾收集器
Serial GC
Parallel GC/Parallel Old GC
Concurrent Mark-Sweep GC (CMS)
说明:
如果GC算法参数搭配不合理,会出现类似错误: