《第2节课作业实践.docx》由会员分享,可在线阅读,更多相关《第2节课作业实践.docx(4页珍藏版)》请在第壹文秘上搜索。
1、第2节课作业实践工、本机使用GlGC启动一个程序,仿照课上案例分析一下JVM情况实践使用我之前写的一个WaiterSerViCeAPPliCatiOn进行演示,这是一个RestService,用于处理咖啡的订单。1 .在IDEA上将此project的VMoptions设置为:-XX:+USeGIGC-XX:MaXGCPaUSeMiIIiS=50ffiRufVDebugConfigurations-H工VAppScation/TcfnptetesNameWdftefServiceApfMicdtionAllowparallelrunConfigurationCodeCoveragelogsSto
2、reasprojectfileMdinc3ss:cxnxMnpleomplexcontrollef.WiteonVMoptions:Programarguments:-XX:WKlCC-XX:UxCCPauMM11is-30Workingdirectory:Environmentvariables:Redirectinputfrom:C:DaUCodeGitHubSpnngFamilyChapter6cocnplex-cotrollerUsedastotmodule1COmPleXYontrOIIefIndudedependefwswithPrvklejps119712;28672Launch
3、er23824RemoteMavenServer3622324Jps;17884WaiterserviceApplicationh.C:DataCode6itHubSpringFamilyChapter6coRplex-controller4 .执行命令:jmap-heap17084,可能因为我电脑上安装的是java11,此命令不好使C:DataCodeGitHubSpringFamilyChapter6coBplex-controllerjpsI19712i26672Launcher:23824RemoteHavenServr3622324JpsI17884WaiterserviceAopl
4、lcatlonC:DataCodeGitHubSpringFanilyChapter6conplex-controllerjnap-heap17884Error:-heapoptionusedCannotconnecttocoredumporremotedebugserver.Usejhsdbj18pInsteadC:DataCodeGitHubSpringFamilyChapter6conple-controlaler5 .根据提示,最终执行命令:jhsdbjmap-heaP-Pidl7084。结果如下:C:DataCodeGitHubSpringFamilyChapter6comple-c
5、ontrollerjhsdbjmap-heap-pid17084AttachingtoprocessID17084,pleasewait.Debuggerattachedsuccessfully.Servercompilerdetected.JVMversionis11.0.2+9-LTSusingthread-localobjectallocation.Garbage-First(Gl)GCwith8thread(s)=40=70 (2000.0MB)HeapConfiguration:MinHeapFreeRatioMaxHeapFreeRatio=(1.2812MB)=(1200.0MB
6、)=(5.21875MB)=2=8=(20.796875MB)MaxHeapSizeNewSizeMaxNewSizeOIdSizeNewRatioSurvivorRatioMetaspaceSizeCompressedciassSpaceSize=(1024.0MB)MaxMetaspaceSize=415MBGlHeapRegionSize=(1.0MB)HeapUsage:GlHeap:regions=2000capacity=(2000.0MB)used=(67.94MB)free=(1932.9MB)3.047%usedGlYoungGeneration:EdenSpace:regi
7、ons=48capacity=(89.0MB)used=(48.0MB)free=(41.0MB)53.92%usedSurvivorSpace:regions=7capacity=(7.0MB)used=(7.0MB)free=O(0.0MB)1OO.O%usedGlOldGeneration:regions=14capacity=(56.0MB)used=(11.938MB)free=(44.906MB)21.104%used6 .从上面的结果可以发现:Garbage-First(Gl)GCwith8thread(s)1已经使用了GlGC,因为我的笔记本有8个CPU,所以是8个线程。Max
8、HeapSize=(2000.0MB),是我笔记本8G内存的四分之一。MaxNewSizeNewSizeOIdSize=(1200.0MB),是MaxHeapSize的60%0=(1.2812MB),年轻代初始值为1.3MB。:(5.21875MB),老年代初始值为5.2MB,GlHeapRegionSize=(1.0MB),2G内存,2048个region,每个region1MB。以新生儿为例:使用了48个region,所有used为48MBoEdenSpace:regions=48capacity=(89.0MB)used=(48.0MB)free=(41.0MB)53.92%used7
9、.打开ViSUalVM,执行一次PerfOrmGC。注:Java11的jdk中不再包含jvisualvm,需要从下载。7 VhUaIVM 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.WterSevcepp
10、kicatn (pd 1704)(0 Owrww Monitor grMds lQ, Sempter Cpromff O com.cxamplcxomplcontrollcr.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,57
11、XXPMRgQPM9Pi40PM Totti IOMldCteMM HSMrV 2X8”,llv: 29D mm on: ?5IgPl: 29Total Urtd: 348.观察jstat-gcutil17084100O100O的执行情况:fflEkMVwHeviQMeCedeAnalytf?ef4CtorcomplexceAppiatc.yaiefCtr.GcZ*E!QtWateSlat)onCOGIPrqleaO-GWAUyfSc?CCAaI-lTefme1:lxa+U-,C:DataCodeGitHubSpringFamilyChapter6cojstat-gcutil17841:Lm1SSlEOMCCSYGCYGCTFGCFGCTCGCCGCTGCTOO.1.73.321.1197.7892.59l.91.6.16.17.1.73.321.1197.7892.59l.91.6.16.17.l.74.1621.1197.7892.59l.91.6.l60.17.l.74.1621.1197.7892.59l.091.68.16.17.0l.74.1621.1197.7892.59l.910.6.16B.177.6.2697.2191.21l.91