今天终于有所斩获,发现了Sun Hotspot JVM GC最全的参数调整列表:
http://blogs.sun.com/watt/resource/jvm-options-list.html
http://www.cnblogs.com/totti19841106/archive/2009/01/12/1374274.html
有关JVM默认值的参考资料如下:
https://gist.github.com/827140
http://hg.openjdk.java.net/jdk6/jdk6/hotspot/file/tip/src/share/vm/runtime/globals.hpp
Java 5以上版本(包含Java 5)GC的调整参数包含以下内容:
1.虚拟机GC性能调整工具参数:
–XX:+PrintGCDetails:
–XX:+PrintGCTimeStamps:
-XX:-DisableExplicitGC
-XX:+UseGCOverheadLimit
-XX:+StringCache
-XX:LargePageSizeInBytes=4m
-Xnoclassgc
-XX:MaxTenuringThreshold=<n>
指定一个 object 在经历了 n 次 young gc 后转移到 old generation 区 , 在 linux64 的 java6 下默认值是 15, 此参数对于 throughput collector 无效 , 如 :-XX:MaxTenuringThreshold=31
-XX:+UseFastAccessorMethods
get,set 方法转成本地代码
-XX:+PrintGCApplicationStoppedTime
打应垃圾收集时 , 系统的停顿时间 , 如 :
Total time for which application threads were stopped: 0.0225920 seconds
-Xmn<n>
指定 jvm 中 New Generation 的大小 , 如 :-Xmn256m。 这个参数很影响性能, 如果你的程序需要比较多的临时内存, 建议设置到512M, 如果用的少, 尽量降低这个数值, 一般来说128/256足以使用了。
-Xss<n>
指定线程桟大小 , 如 :-Xss128k, 一般来说,webx框架下的应用需要256K。 如果你的程序有大规模的递归行为, 请考虑设置到512K/1M。 这个需要全面的测试才能知道。 不过, 256K已经很大了。 这个参数对性能的影响比较大的。
-XX:PretenureSizeThreshold =<value>:当对象大于该值就直接分配到堆的 ‘老生代’ 区域
2.GC的关键选项参数:
2.1堆和代的大小调整参数
Option | Default | Description |
-Xms<n> | Initial size, in bytes, of the heap. | |
–Xmx<n> | Maximum size, in bytes, of the heap. | |
–XX:MinHeapFreeRatio=minimum and –XX:MaxHeapFreeRatio=maximum | 40 (min) 70 (max) | Target range for the proportion of free space to total heap size. These are applied per generation. For example, if minimum is 30 and the percent of free space in a generation falls below 30%, the size of the generation is expanded so as to have 30% of the space free. Similarly, if maximum is 60 and the percent of free space exceeds 60%, the size of the generation is shrunk so as to have only 60% of the space free. |
–XX:NewSize=n | Default initial size of the new (young) generation in bytes. | |
–XX:NewRatio=n | 2 on client JVM, 8 on server JVM | Ratio between the young and old generations. For example, if n is 3, then the ratio is 1:3 and the combined size of Eden and the survivor spaces is one fourth of the total size of the young and old generations. |
–XX:SurvivorRatio=n | 32 | Ratio between each survivor space and Eden. For example, if n is 7, each survivor space is one–ninth of the young generation (not one–eighth, because there are two survivor spaces). |
–XX:MaxPermSize=n | Platform–dependent | Maximum size of the permanent generation. |
2.3垃圾回收器选择参数
Option | Garbage Collector Selected |
–XX:+UseSerialGC | 串行回收器 |
–XX:+UseParallelGC | 并行回收器 |
–XX:+UseParallelOldGC | Parallel compacting |
–XX:+UseConcMarkSweepGC |
Concurrent mark–sweep (CMS)
2.4并行(Java5 以及以上版本-Server 模式默认的垃圾回收器)和并行压缩垃圾回收器的GC调整参数
Option | Default | Description |
–XX:ParallelGCThreads=n | The number of CPUs | Number of garbage collector threads. |
–XX:MaxGCPauseMillis=n | No default | Indicates to the collector that pause times of n milliseconds or less are desired. |
–XX:GCTimeRatio=n | 99 | Number that sets a goal that 1/(1+n) of the total time be spent on garbage collection. |
2.5 CMS垃圾回收器的GC调整参数
Option | Default | Description |
–XX:+CMSIncrementalMode | Disabled | Enables a mode in which the concurrent phases are done incrementally, periodically stopping the concurrent phase to yield back the processor to the application. |
–XX:+CMSIncrementalPacing | Disabled | Enables automatic control of the amount of work the CMS collector is allowed to do before giving up the processor, based on application behavior. |
–XX:ParallelGCThreads=n | The number of CPUs | Number of garbage collector threads for the parallel young generation collections and for the parallel parts of the old generation collections. |
补充参数:
-XX:CMSInitiatingOccupancyFraction
-XX:+CMSPermGenSweepingEnabled
-XX:+CMSClassUnloadingEnabled
-XX:+UseCMSInitiatingOccupancyOnly
指示只有在 old generation 在使用了初始化的比例后 concurrent collector 启动收集
http://java.sun.com/javase/technologies/hotspot/vmoptions.jsp
http://www.md.pp.ru/~eu/jdk6options.html