Windows注册表路径:HKEY_LOCAL_MACHINE->SOFTWARE->Wow6432Node->Apache Software Foundation->Procrun 2.0->tomcat的服务名字->Parameters->Java->Options
-Xms896m
-Xmx2048m
-XX:PermSize=256m
-XX:MaxPermSize=648m
-verbose:gc
-XX:+PrintGC
-XX:+PrintGCDetails
-XX:+PrintTenuringDistribution
-XX:+PrintHeapAtGC
-XX:+PrintGCTimeStamps
-XX:+PrintGCDateStamps
-XX:+HeapDumpOnOutOfMemoryError
-loggc:C:/apps/tomcat/logs/tomcat_gc.log
-Dcatalina.base=C:/apps/tomcat
-Dcatalina.home=C:/apps/tomcat
-Djava.endorsed.dirs=C:/apps/tomcat/endorsed
-Dextend.library.path=C:/extend_library
-Djava.io.tmpdir=C:/tomcat/temp
-Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager
-Djava.util.logging.config.file=C:/apps/tomcat/conf/logging.properties
备注:
1、必须使用正斜杠
2、不能存在空行以及空格(比如:-XX:+PrintGCDetails中,冒号与加号之间不能有空格;加号与P之间不能有空格;X与冒号之间不能有空格)
3、每一个配置项单独占用一行
4、所涉及的路径必须存在
--------------------------------------------------------------GC日志相关的配置项如下开始------------------------------------------------
-verbose:gc:
表示输出虚拟机中GC的详细情况,使用后输出如下:
12.537: [Full GC 168K->97K(1984K), 0.0253873 secs]
-XX:+PrintGC
使用后输出如下:
13.290: [GC 230400K->13846K(880128K), 0.0473673 secs]
这个选项与-verbose:gc是一样的,可以认为-verbose:gc是-XX:+PrintGC的别名
-XX:+PrintGCDetails
使用后,输出如下:
12.608: [GC [PSYoungGen: 230400K->13766K(268288K)] 230400K->13838K(880128K), 0.0511429 secs] [Times: user=0.11 sys=0.01, real=0.05 secs]
备注:
这个选项在启动脚本可以自动开启-XX:+PrintGC,如果在命令行使用jinfo开启的话,不会自动开启-XX:+PrintGC
-XX:+PrintTenuringDistribution
使用后,输出如下:
12.669: [GC
Desired survivor size 38797312 bytes, new threshold 7 (max 15)
230400K->13757K(880128K), 0.0415991 secs]
-XX:+PrintHeapAtGC
使用后,输出如下:
13.209: [GC 230400K->13964K(880128K), 0.0410904 secs]
Heap after GC invocations=1 (full 0):
PSYoungGen total 268288K, used 13892K [0x00000007d5500000, 0x00000007e8000000, 0x0000000800000000)
eden space 230400K, 0% used [0x00000007d5500000,0x00000007d5500000,0x00000007e3600000)
from space 37888K, 36% used [0x00000007e3600000,0x00000007e4391070,0x00000007e5b00000)
to space 37888K, 0% used [0x00000007e5b00000,0x00000007e5b00000,0x00000007e8000000)
ParOldGen total 611840K, used 72K [0x0000000780000000, 0x00000007a5580000, 0x00000007d5500000)
object space 611840K, 0% used [0x0000000780000000,0x0000000780012010,0x00000007a5580000)
PSPermGen total 262144K, used 15723K [0x0000000757800000, 0x0000000767800000, 0x0000000780000000)
object space 262144K, 5% used [0x0000000757800000,0x000000075875acb8,0x0000000767800000)
}
{Heap before GC invocations=2 (full 0):
PSYoungGen total 268288K, used 244292K [0x00000007d5500000, 0x00000007e8000000, 0x0000000800000000)
eden space 230400K, 100% used [0x00000007d5500000,0x00000007e3600000,0x00000007e3600000)
from space 37888K, 36% used [0x00000007e3600000,0x00000007e4391070,0x00000007e5b00000)
to space 37888K, 0% used [0x00000007e5b00000,0x00000007e5b00000,0x00000007e8000000)
ParOldGen total 611840K, used 72K [0x0000000780000000, 0x00000007a5580000, 0x00000007d5500000)
object space 611840K, 0% used [0x0000000780000000,0x0000000780012010,0x00000007a5580000)
PSPermGen total 262144K, used 31698K [0x0000000757800000, 0x0000000767800000, 0x0000000780000000)
object space 262144K, 12% used [0x0000000757800000,0x00000007596f4b00,0x0000000767800000)
-XX:+PrintGCTimeStamps
使用后,输出如下:
14.087: [GC 230400K->13955K(880128K), 0.0562136 secs]
-XX:+PrintGCDateStamps
使用后,输出如下:
2017-03-31T20:19:51.541-0700: 14.244: [GC 230400K->13977K(880128K), 0.0491532 secs]
-XX:+HeapDumpOnOutOfMemoryError
使用后,输出如下:
13.512: [GC 230400K->13898K(880128K), 0.0618803 secs]
-loggc:C:/apps/tomcat/logs/tomcat_gc.log
--------------------------------------------------------------GC日志相关的配置项如下结束------------------------------------------------
ConcMarkSweeping+ParNew进行垃圾回收配置如下:
-Xms1024M
-Xmx4096M
-XX:PermSize=256M
-XX:MaxPermSize=1024M
-XX:NewRatio=3
-XX:SurvivorRatio=500
-XX:+UseParNewGC
-XX:ParallelGCThreads=10
-XX:+UseConcMarkSweepGC
-XX:+CMSParallelRemarkEnabled
-XX:+CMSScavengeBeforeRemark
-XX:+PrintTenuringDistribution
-XX:ParallelCMSThreads=10
-XX:CMSInitiatingOccupancyFraction=65
-XX:MaxTenuringThreshold=3
-XX:+UseCMSInitiatingOccupancyOnly
-XX:+UseCMSCompactAtFullCollection
-XX:CMSFullGCsBeforeCompaction=0
-XX:+CMSPermGenSweepingEnabled
-XX:+CMSClassUnloadingEnabled
-XX:+UseFastAccessorMethods
-verbose:gc
-XX:+PrintGC
-XX:+PrintGCDetails
-XX:+PrintTenuringDistribution
-XX:+PrintHeapAtGC
-XX:+PrintGCTimeStamps
-XX:+PrintGCDateStamps
-XX:+HeapDumpOnOutOfMemoryError
-XX:HeapDumpPath=C:/CMS/ivms_install/apps/tomcat-lite/logs
-Xloggc:C:/CMS/ivms_install/apps/tomcat-lite/logs/tomcat_gc.log
-Dcatalina.base=C:/CMS/ivms_install/apps/tomcat-lite
-Dcatalina.home=C:/CMS/ivms_install/apps/tomcat-lite
-Djava.endorsed.dirs=C:/CMS/ivms_install/apps/tomcat-lite/endorsed
-Dextend.library.path=C:/CMS/ivms_install/extend_library
-Djava.io.tmpdir=C:/CMS/ivms_install/apps/tomcat-lite/temp
-Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager
-Djava.util.logging.config.file=C:/CMS/ivms_install/apps/tomcat-lite/conf/logging.properties
GC实例(ParNew结合CMS):
http://blog.csdn.net/g7n3f/article/details/50828793
新生代垃圾回收分析实例:
http://www.cnblogs.com/xingele0917/p/4270188.html
http://blog.csdn.net/g7n3f/article/details/50828793
垃圾回收工具使用:
http://hugoren.iteye.com/blog/2281855
垃圾回收器的发展历史:
https://blogs.oracle.com/jonthecollector/entry/our_collectors
服务器快速调优:
http://blog.itpub.net/30089851/viewspace-2121380/
参考: