《第2节课作业实践.docx》由会员分享,可在线阅读,更多相关《第2节课作业实践.docx(4页珍藏版)》请在第一文库网上搜索。
1、第2节课作业实践工、本机使用GlGC启动一个程序,仿照课上案例分析一下JVM情况实践使用我之前写的一个WaiterSerViCeAPPliCatiOn进行演示,这是一个Rest Service,用于处理咖啡的 订单。1 . 在 IDEA 上将此 project 的 VM options 设置为:-XX:+USeGIGC -XX:MaXGCPaUSeMiIIiS=50ffi RufVDebug Configurations - H 工V AppScation / TcfnptetesName WdftefServiceApfMicdtionAllow parallel runConfigurat
2、ion Code Coverage logsStore as project fileMdin c3ss:cxnxMnpleomplexcontrollef.WiteonVM options:Program arguments:-XX: WKlCC -XX:UxCCPauMM 11 i s-30Working directory:Environment variables:Redirect input from:C:DaUCodeGitHubSpnngFamilyChapter 6cocnplex-cotrollerUse dast ot module1 COmPleXYontrOIIefIn
3、dude dependefws with Prvklejps 1 19712;28672 Launcher23824 RemoteMavenServer36 22324 Jps;17884 WaiterserviceApplicationh.C:DataCode6itHubSpringFamilyChapter 6coRplex-controller4 .执行命令:jmap-heap 17084,可能因为我电脑上安装的是java 11,此命令不好使 C:DataCodeGitHubSpringFamilyChapter 6coBplex-controllerjpsI 19712i 26672
4、Launcher:23824 RemoteHavenServr3622324 JpsI 17884 WaiterserviceAopllcatlonC:DataCodeGitHubSpringFanilyChapter 6conplex-controllerjnap -heap 17884 Error: -heap option usedCannot connect to core dump or remote debug server. Use jhsdb j18p InsteadC: DataCodeGitHubSpringFamilyChapter 6conple-controlaler
5、5 .根据提示,最终执行命令:jhsdbjmap-heaP-Pidl7084。结果如下:C:DataCodeGitHubSpringFamilyChapter 6comple-controllerjhsdb jmap -heap -pid 17084Attaching to process ID 17084, please wait.Debugger attached successfully.Server compiler detected.JVM version is 11.0.2+9-LTSusing thread-local object allocation.Garbage-Firs
6、t (Gl) GC with 8 thread(s)=40=70 (2000.0MB)Heap Configuration: MinHeapFreeRatio MaxHeapFreeRatio=(1.2812MB)=(1200.0MB)=(5.21875MB)=2=8=(20.796875MB)MaxHeapSize NewSize MaxNewSize OIdSize NewRatio SurvivorRatio MetaspaceSizeCompressedciassSpaceSize = (1024.0MB)MaxMetaspaceSize= 415 MBGlHeapRegionSize
7、= (1.0MB)Heap Usage:Gl Heap:regions = 2000capacity = (2000.0MB) used = (67.94MB) free = (1932.9MB) 3.047% usedGl Young Generation: Eden Space:regions = 48 capacity = (89.0MB) used = (48.0MB) free = (41.0MB) 53.92% usedSurvivor Space: regions = 7 capacity = (7.0MB) used = (7.0MB) free = O (0.0MB) 1OO
8、.O% usedGl Old Generation: regions = 14 capacity = (56.0MB) used = (11.938MB) free = (44.906MB) 21.104% used6 .从上面的结果可以发现:Garbage-First (Gl) GC with 8 thread(s)1 已经使用了 GlGC,因为我的笔记本有 8 个 CPU, 所以是8个线程。MaxHeapSize = (2000.0MB),是我笔记本8G内存的四分之一。MaxNewSizeNewSizeOIdSize=(1200.0MB),是 MaxHeapSize 的 60%0 =(1.
9、2812MB),年轻代初始值为1.3MB。 :(5.21875MB),老年代初始值为5.2MB,GlHeapRegionSize = (1.0MB), 2G 内存,2048 个 region,每个 region 1MB。以新生儿为例:使用了 48个region,所有used为48MBoEden Space:regions = 48capacity = (89.0MB)used = (48.0MB)free = (41.0MB)53.92% used7 .打开 ViSUalVM,执行一次 PerfOrm GC。注:Java 11的jdk中不再包含jvisualvm,需要从下载。7 VhUaIVM
10、 244Fe AppIiCAbom View TooH Window Help中禽事检曲包96-5zln-j Local MitVM器 lde(pd l”12) g.)(brMCLidAjnaMc.fi(vrRmoM*VoftSarVS623024)A oqj.)ebrnskp,cmdnelunkr (p0 20672)叁 Remote VM Coftdumps J6R Snptts Stsoom.exampleompcontroter.WterSevceppkicatn (pd 1704)(0 Owrww Monitor grMds lQ, Sempter Cpromff O com.cxa
11、mplcxomplcontrollcr.WditcfS y: 0JGC activity: 0.0UMH-%0% * -1务办 20*9:57530”fcS7H0FH CFU u9 CC MtfvffyI Perform CC I M8 DumpMMp MtMpC* 3:1H.33M UMd: S4,6,7X tMaX:44X.3X,032BTotal loaded: 11.624SharMd: OShMd unloaded: OIOJJOOsmOllT,57XXPMRgQPM9Pi40PM Totti IOMldCteMM HSMrV 2X8”,llv: 29D mm on: ?5IgPl:
12、 29Total Urtd: 348.观察 jstat -gcutil 17084 IOOO IOOO 的执行情况:ffl Ek M Vw HeviQMe Cede Analytf? ef4CtorcomplexceAppiatc .yaiefCtr.Gc Z* E! QtWateSlat)on COG I Prqlea O -G WAUyfSc?CCAaI-l Tefme1:lxa +U -,C:DataCodeGitHubSpringFamilyChapter 6cojstat -gcutil 17841 :Lm1SSlEOMCCSYGCYGCTFGCFGCTCGCCGCTGCTOO.1.73.321.1197.7892.59l.91.6.16.17.1.73.321.1197.7892.59l.91.6.16.17.l.