tomcat之JVM GC 日誌文件生成

Windows註冊表路徑:HKEY_LOCAL_MACHINE->SOFTWARE->Wow6432Node->Apache Software Foundation->Procrun 2.0->tomcat的服務名字->Parameters->Java->Optionshtml

-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.propertiesjava

備註:apache

一、必須使用正斜槓tomcat

二、不能存在空行以及空格(好比:-XX:+PrintGCDetails中,冒號與加號之間不能有空格;加號與P之間不能有空格;X與冒號之間不能有空格)服務器

三、每個配置項單獨佔用一行oracle

四、所涉及的路徑必須存在app

--------------------------------------------------------------GC日誌相關的配置項以下開始------------------------------------------------工具

-verbose:gc: spa

表示輸出虛擬機中GC的詳細狀況,使用後輸出以下:.net

12.537: [Full GC 168K->97K(1984K), 0.0253873 secs]

解讀以下:
  12.537表示距離tomcat啓動時間爲12.537秒;箭頭先後的數據168K和97K分別表示垃圾收集GC先後全部存活對象使用的內存容量,說明有168K-97K=71K的對象容量被回收,括號內的數據1984K爲堆內存的總容量,收集所須要的時間是0.0253873秒(這個時間在每次執行的時候會有所不一樣)
備註:GC會暫用CPU時間片,有可能形成應用程序在某個時刻極短的停頓.


-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/

 

參考:

 http://www.ishuo.cn/doc/oaezziqf.html

相關文章
相關標籤/搜索