今天我們的系列文章要介紹的是這四個(gè)工具:
創(chuàng)新互聯(lián)建站長(zhǎng)期為上千余家客戶提供的網(wǎng)站建設(shè)服務(wù),團(tuán)隊(duì)從業(yè)經(jīng)驗(yàn)10年,關(guān)注不同地域、不同群體,并針對(duì)不同對(duì)象提供差異化的產(chǎn)品和服務(wù);打造開放共贏平臺(tái),與合作伙伴共同營(yíng)造健康的互聯(lián)網(wǎng)生態(tài)環(huán)境。為陳巴爾虎企業(yè)提供專業(yè)的做網(wǎng)站、網(wǎng)站制作,陳巴爾虎網(wǎng)站改版等技術(shù)服務(wù)。擁有10年豐富建站經(jīng)驗(yàn)和眾多成功案例,為您定制開發(fā)。Jstat(sun.tools.jstat) 它的全稱是Java Virtual Machine Statistics Monitoring Tool,是用來(lái)監(jiān)控JVM狀態(tài)的工具。
jstack(sun.tools.jstack) 它的全稱是Java Stack Trace,是用來(lái)做java棧的跟蹤工具。
jmap(sun.tools.jmap) 它的全稱是Java Memory Map,是java的內(nèi)存管理工具。
jhat (com.sun.tools.hat.Main) 它的全稱是Java Heap Analyse Tool,是java的堆分析工具。
有了這四個(gè)工具,基本上JVM運(yùn)行期間的方方面面都可以被覆蓋到了。下面我們將具體對(duì)每一個(gè)工具進(jìn)行詳細(xì)講解。本文將會(huì)首先講解Jstat的具體使用。
jstat主要對(duì)JVM運(yùn)行期間的各種參數(shù)進(jìn)行收集,包括查看類的加載情況,jc中新生代老年代元數(shù)據(jù)空間的使用情況等。
先看下Jstat的命令:
jstat outputOptions [-t] [-h lines] vmid [interval [count]]
上面我們講了JStat命令的基本格式,在本節(jié)我們會(huì)詳細(xì)講解JStat的輸出選項(xiàng)。
使用jstat -options可以看到j(luò)stat支持的幾個(gè)options選項(xiàng):
jstat -options -class-compiler-gc-gccapacity-gccause-gcmetacapacity-gcnew-gcnewcapacity-gcold-gcoldcapacity-gcutil-printcompilation
輸出class loader的統(tǒng)計(jì)信息,我們舉個(gè)例子:
jstat -class -t 53528 100 5Timestamp Loaded Bytes Unloaded Bytes Time 19822.8 5214 10752.5 0 0.0 2.91 19823.0 5214 10752.5 0 0.0 2.91 19823.0 5214 10752.5 0 0.0 2.91 19823.2 5214 10752.5 0 0.0 2.91 19823.2 5214 10752.5 0 0.0 2.91
上面的例子中53528是目標(biāo)JVM的pid,100表示取樣的間隔時(shí)間是100ms,5表示最后只展示5條數(shù)據(jù)。
上面的Timestamp表示的JVM的啟動(dòng)的時(shí)間。
compiler統(tǒng)計(jì)的是Java HotSpot VM Just-in-Time JIT即時(shí)編譯器的信息。
JIT即時(shí)編譯器是為了提升代碼的執(zhí)行速度而產(chǎn)生的。JVM對(duì)于一些熱點(diǎn)代碼,比如多次循環(huán)和經(jīng)常使用的方法。對(duì)于這些熱點(diǎn)代碼,JIT會(huì)將其編譯成機(jī)器代碼,從而提升執(zhí)行速度。
還是舉剛剛的JVM的例子:
jstat -compiler 53528 100 5Compiled Failed Invalid Time FailedType FailedMethod 2675 0 0 5.35 0 2675 0 0 5.35 0 2675 0 0 5.35 0 2675 0 0 5.35 0 2675 0 0 5.35 0
gc統(tǒng)計(jì)的是gc heap信息
jstat -gc 53528 100 5 S0C S1C S0U S1U EC EU OC OU MC MU CCSC CCSU YGC YGCT FGC FGCT CGC CGCT GCT 0.0 4096.0 0.0 3978.2 56320.0 33792.0 15360.0 15215.0 21552.0 20680.9 2688.0 2468.0 4 0.025 0 0.000 2 0.003 0.028 0.0 4096.0 0.0 3978.2 56320.0 33792.0 15360.0 15215.0 21552.0 20680.9 2688.0 2468.0 4 0.025 0 0.000 2 0.003 0.028 0.0 4096.0 0.0 3978.2 56320.0 33792.0 15360.0 15215.0 21552.0 20680.9 2688.0 2468.0 4 0.025 0 0.000 2 0.003 0.028 0.0 4096.0 0.0 3978.2 56320.0 33792.0 15360.0 15215.0 21552.0 20680.9 2688.0 2468.0 4 0.025 0 0.000 2 0.003 0.028 0.0 4096.0 0.0 3978.2 56320.0 33792.0 15360.0 15215.0 21552.0 20680.9 2688.0 2468.0 4 0.025 0 0.000 2 0.003 0.028
gc的輸出參數(shù)比較多,我們一一進(jìn)行解釋,這樣大家對(duì)于gc的運(yùn)行內(nèi)核會(huì)有更多的理解:
Young Gen被劃分為1個(gè)Eden Space和2個(gè)Suvivor Space。當(dāng)對(duì)象剛剛被創(chuàng)建的時(shí)候,是放在Eden space。垃圾回收的時(shí)候,會(huì)掃描Eden Space和一個(gè)Suvivor Space。如果在垃圾回收的時(shí)候發(fā)現(xiàn)Eden Space中的對(duì)象仍然有效,則會(huì)將其復(fù)制到另外一個(gè)Suvivor Space。
就這樣不斷的掃描,最后經(jīng)過(guò)多次掃描發(fā)現(xiàn)任然有效的對(duì)象會(huì)被放入Old Gen表示其生命周期比較長(zhǎng),可以減少垃圾回收時(shí)間。
在JDK8之前,類定義、字節(jié)碼和常量等很少會(huì)變更的信息是放在持久代Perm Gen中的。不過(guò)在JDK8之后,Perm Gen已經(jīng)被取消了,現(xiàn)在叫做Metaspace。Metaspace并不在java虛擬機(jī)中,它使用的是本地內(nèi)存。Metaspace可以通過(guò)-XX:MaxMetaspaceSize來(lái)控制。
Compressed Class Space,它是和-XX:+UseCompressedOops,-XX:+UseCompressedClassesPointers有關(guān)的。實(shí)際上是一個(gè)指針的壓縮,可以使用32bits來(lái)表示之前64bits的指針。
gccapacity統(tǒng)計(jì)的是內(nèi)存池的創(chuàng)建和大小等統(tǒng)計(jì)信息
jstat -gccapacity 53528 100 5 NGCMN NGCMX NGC S0C S1C EC OGCMN OGCMX OGC OC MCMN MCMX MC CCSMN CCSMX CCSC YGC FGC CGC 0.0 716800.0 60416.0 0.0 4096.0 56320.0 0.0 716800.0 15360.0 15360.0 0.0 1069056.0 21552.0 0.0 1048576.0 2688.0 4 0 2 0.0 716800.0 60416.0 0.0 4096.0 56320.0 0.0 716800.0 15360.0 15360.0 0.0 1069056.0 21552.0 0.0 1048576.0 2688.0 4 0 2 0.0 716800.0 60416.0 0.0 4096.0 56320.0 0.0 716800.0 15360.0 15360.0 0.0 1069056.0 21552.0 0.0 1048576.0 2688.0 4 0 2 0.0 716800.0 60416.0 0.0 4096.0 56320.0 0.0 716800.0 15360.0 15360.0 0.0 1069056.0 21552.0 0.0 1048576.0 2688.0 4 0 2 0.0 716800.0 60416.0 0.0 4096.0 56320.0 0.0 716800.0 15360.0 15360.0 0.0 1069056.0 21552.0 0.0 1048576.0 2688.0 4 0 2
gcnew表示新生代的統(tǒng)計(jì)信息
jstat -gcnew 53528 100 5 S0C S1C S0U S1U TT MTT DSS EC EU YGC YGCT 0.0 4096.0 0.0 3978.2 15 15 5120.0 56320.0 33792.0 4 0.025 0.0 4096.0 0.0 3978.2 15 15 5120.0 56320.0 33792.0 4 0.025 0.0 4096.0 0.0 3978.2 15 15 5120.0 56320.0 33792.0 4 0.025 0.0 4096.0 0.0 3978.2 15 15 5120.0 56320.0 33792.0 4 0.025 0.0 4096.0 0.0 3978.2 15 15 5120.0 56320.0 33792.0 4 0.025
gcnewcapacity統(tǒng)計(jì)的是新生代的指標(biāo),和gccapacity的結(jié)果是很類似的:
jstat -gcnewcapacity 53528 100 5 NGCMN NGCMX NGC S0CMX S0C S1CMX S1C ECMX EC YGC FGC CGC 0.0 716800.0 60416.0 0.0 0.0 716800.0 4096.0 716800.0 56320.0 4 0 2 0.0 716800.0 60416.0 0.0 0.0 716800.0 4096.0 716800.0 56320.0 4 0 2 0.0 716800.0 60416.0 0.0 0.0 716800.0 4096.0 716800.0 56320.0 4 0 2 0.0 716800.0 60416.0 0.0 0.0 716800.0 4096.0 716800.0 56320.0 4 0 2 0.0 716800.0 60416.0 0.0 0.0 716800.0 4096.0 716800.0 56320.0 4 0 2
gcold統(tǒng)計(jì)old代的信息
jstat -gcold 53528 100 5 MC MU CCSC CCSU OC OU YGC FGC FGCT CGC CGCT GCT 21552.0 20680.9 2688.0 2468.0 15360.0 15215.0 4 0 0.000 2 0.003 0.028 21552.0 20680.9 2688.0 2468.0 15360.0 15215.0 4 0 0.000 2 0.003 0.028 21552.0 20680.9 2688.0 2468.0 15360.0 15215.0 4 0 0.000 2 0.003 0.028 21552.0 20680.9 2688.0 2468.0 15360.0 15215.0 4 0 0.000 2 0.003 0.028 21552.0 20680.9 2688.0 2468.0 15360.0 15215.0 4 0 0.000 2 0.003 0.028
結(jié)果的幾項(xiàng)指標(biāo)前面已經(jīng)介紹過(guò)了,這里就不再重復(fù)了
gcoldcapacity表示old代的容量信息
jstat -gcoldcapacity 53528 100 5 OGCMN OGCMX OGC OC YGC FGC FGCT CGC CGCT GCT 0.0 716800.0 15360.0 15360.0 4 0 0.000 2 0.003 0.028 0.0 716800.0 15360.0 15360.0 4 0 0.000 2 0.003 0.028 0.0 716800.0 15360.0 15360.0 4 0 0.000 2 0.003 0.028 0.0 716800.0 15360.0 15360.0 4 0 0.000 2 0.003 0.028 0.0 716800.0 15360.0 15360.0 4 0 0.000 2 0.003 0.028
gcmetacapacity統(tǒng)計(jì)的是元數(shù)據(jù)區(qū)域的容量信息
jstat -gcmetacapacity 53528 100 5 MCMN MCMX MC CCSMN CCSMX CCSC YGC FGC FGCT CGC CGCT GCT 0.0 1069056.0 21552.0 0.0 1048576.0 2688.0 4 0 0.000 2 0.003 0.028 0.0 1069056.0 21552.0 0.0 1048576.0 2688.0 4 0 0.000 2 0.003 0.028 0.0 1069056.0 21552.0 0.0 1048576.0 2688.0 4 0 0.000 2 0.003 0.028 0.0 1069056.0 21552.0 0.0 1048576.0 2688.0 4 0 0.000 2 0.003 0.028 0.0 1069056.0 21552.0 0.0 1048576.0 2688.0 4 0 0.000 2 0.003 0.028
gcutil統(tǒng)計(jì)的是GC總體的情況
jstat -gcutil 53528 100 5 S0 S1 E O M CCS YGC YGCT FGC FGCT CGC CGCT GCT 0.00 97.12 60.00 99.06 95.96 91.82 4 0.025 0 0.000 2 0.003 0.028 0.00 97.12 60.00 99.06 95.96 91.82 4 0.025 0 0.000 2 0.003 0.028 0.00 97.12 60.00 99.06 95.96 91.82 4 0.025 0 0.000 2 0.003 0.028 0.00 97.12 60.00 99.06 95.96 91.82 4 0.025 0 0.000 2 0.003 0.028 0.00 97.12 60.00 99.06 95.96 91.82 4 0.025 0 0.000 2 0.003 0.028
gccause和gcutil非常相識(shí),只不過(guò)多了下面兩列:
jstat -gccause 53528 100 5 S0 S1 E O M CCS YGC YGCT FGC FGCT CGC CGCT GCT LGCC GCC 0.00 97.12 60.00 99.06 95.96 91.82 4 0.025 0 0.000 2 0.003 0.028 Metadata GC Threshold No GC 0.00 97.12 60.00 99.06 95.96 91.82 4 0.025 0 0.000 2 0.003 0.028 Metadata GC Threshold No GC 0.00 97.12 60.00 99.06 95.96 91.82 4 0.025 0 0.000 2 0.003 0.028 Metadata GC Threshold No GC 0.00 97.12 60.00 99.06 95.96 91.82 4 0.025 0 0.000 2 0.003 0.028 Metadata GC Threshold No GC 0.00 97.12 60.00 99.06 95.96 91.82 4 0.025 0 0.000 2 0.003 0.028 Metadata GC Threshold No GC
printcompilation是JVM編譯器的方法統(tǒng)計(jì)
jstat -printcompilation 53528 100 5Compiled Size Type Method 2675 23 1 jdk/internal/misc/InnocuousThread eraseThreadLocals 2675 23 1 jdk/internal/misc/InnocuousThread eraseThreadLocals 2675 23 1 jdk/internal/misc/InnocuousThread eraseThreadLocals 2675 23 1 jdk/internal/misc/InnocuousThread eraseThreadLocals 2675 23 1 jdk/internal/misc/InnocuousThread eraseThreadLocals
本文介紹了JDK14中自帶的jstat JVM分析工具,希望大家能夠在實(shí)際的工作中用到。
https://www.imdb.com/list/ls080419900/?publish=publish
https://www.imdb.com/list/ls080419956/?publish=publish
https://www.imdb.com/list/ls080419916/?publish=publish
https://www.imdb.com/list/ls080419990/?publish=publish
https://www.imdb.com/list/ls080419855/?publish=publish
https://www.imdb.com/list/ls080419867/?publish=publish
https://www.imdb.com/list/ls080418035/?publish=publish
https://www.imdb.com/list/ls080418063/?publish=publish
https://www.imdb.com/list/ls080418085/?publish=publish
https://www.imdb.com/list/ls080418713/?publish=publish
https://www.imdb.com/list/ls080418783/?publish=publish
https://www.imdb.com/list/ls080418174/?publish=publish
https://www.imdb.com/list/ls080418113/?publish=publish
https://www.imdb.com/list/ls080418138/?publish=publish
https://www.imdb.com/list/ls080418184/?publish=publish
https://www.imdb.com/list/ls080418326/?publish=publish
https://www.imdb.com/list/ls080418399/?publish=publish
https://www.imdb.com/list/ls080418659/?publish=publish
https://www.imdb.com/list/ls080418638/?publish=publish
https://www.imdb.com/list/ls080418696/?publish=publish
https://www.imdb.com/list/ls080418253/?publish=publish
https://www.imdb.com/list/ls080418274/?publish=publish
https://www.imdb.com/list/ls080418239/?publish=publish
https://www.imdb.com/list/ls080418248/?publish=publish
https://www.imdb.com/list/ls080418280/?publish=publish
https://www.imdb.com/list/ls080418459/?publish=publish
https://www.imdb.com/list/ls080418481/?publish=publish
https://www.imdb.com/list/ls080418875/?publish=publish
https://www.imdb.com/list/ls080418874/?publish=publish
https://www.imdb.com/list/ls080418834/?publish=publish
https://www.imdb.com/list/ls080418869/?publish=publish
https://www.imdb.com/list/ls080418844/?publish=publish
https://www.imdb.com/list/ls080430017/?publish=publish
https://www.imdb.com/list/ls080430045/?publish=publish
https://www.imdb.com/list/ls080430562/?publish=publish
https://www.imdb.com/list/ls080430172/?publish=publish
https://www.imdb.com/list/ls080430111/?publish=publish
https://www.imdb.com/list/ls080430167/?publish=publish
https://www.imdb.com/list/ls080430191/?publish=publish
https://www.imdb.com/list/ls080430314/?publish=publish
https://www.imdb.com/list/ls080430389/?publish=publish
https://www.imdb.com/list/ls080430652/?publish=publish
https://www.imdb.com/list/ls080430614/?publish=publish
當(dāng)前名稱:JDK14性能管理工具:jstat使用介紹-創(chuàng)新互聯(lián)
標(biāo)題路徑:http://www.rwnh.cn/article8/ceccop.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供ChatGPT、自適應(yīng)網(wǎng)站、建站公司、定制開發(fā)、網(wǎng)站建設(shè)、網(wǎng)頁(yè)設(shè)計(jì)公司
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來(lái)源: 創(chuàng)新互聯(lián)
猜你還喜歡下面的內(nèi)容