{"id":2822,"date":"2018-06-02T11:59:29","date_gmt":"2018-06-02T03:59:29","guid":{"rendered":"http:\/\/www.xttblog.com\/?p=2822"},"modified":"2018-06-02T11:59:29","modified_gmt":"2018-06-02T03:59:29","slug":"%e5%94%af%e5%93%81%e4%bc%9a-vjmap-%e6%95%99%e7%a8%8b","status":"publish","type":"post","link":"https:\/\/www.xttblog.com\/?p=2822","title":{"rendered":"\u552f\u54c1\u4f1a vjmap \u6559\u7a0b"},"content":{"rendered":"<p>\n\tvjmap \u662f\u552f\u54c1\u4f1a\u5f00\u6e90\u51fa\u6765\u7684 vjtools \u5de5\u5177\u96c6\u7684\u4e00\u4e2a\u7528\u6765\u6392\u67e5 java \u5185\u5b58\u6cc4\u6f0f\u7684\u5de5\u5177\u3002\u4e0e\u8fd1\u65e5\u5728 github \u4e0a\u5f00\u6e90\uff0c\u672c\u6587\u5c06\u8be6\u7ec6\u4ecb\u7ecd vjmap \u7684\u76f8\u5173\u7528\u6cd5\u3002\n<\/p>\n<h2>\n\t\u6982\u8ff0<br \/>\n<\/h2>\n<p>\n\t\u5206\u4ee3\u7248\u7684jmap\uff08\u65b0\u751f\u4ee3\uff0c\u5b58\u6d3b\u533a\uff0c\u8001\u751f\u4ee3\uff09\uff0c\u662f\u6392\u67e5\u5185\u5b58\u7f13\u6162\u6cc4\u9732\uff0c\u8001\u751f\u4ee3\u589e\u957f\u8fc7\u5feb\u539f\u56e0\u7684\u5229\u5668\u3002\u56e0\u4e3a<code>jmap -histo PID<\/code>&nbsp;\u6253\u5370\u7684\u662f\u6574\u4e2aHeap\u7684\u5bf9\u8c61\u4fe1\u606f\uff0c\u800c\u5f88\u591a\u65f6\u5019\uff0c\u6211\u4eec\u9700\u8981\u4e13\u95e8\u67e5\u770bOldGen\u5bf9\u8c61\uff0c\u4ee5\u53casurvivor\u533aAge\u8f83\u5927\u7684\u5bf9\u8c61\u3002\n<\/p>\n<p>\n\tvjmap \u539f\u59cb\u601d\u8def\u6765\u6e90\u4e8eR\u5927\u7684<a href=\"https:\/\/github.com\/alibaba\/TBJMap\">tbjmap<\/a>&nbsp;\uff0c\u7ffb\u65b0\u540e\u517c\u5bb9JDK8\uff0c\u652f\u6301\u5bf9\u5b58\u6d3b\u533a\u8001\u9f84\u5269\u4f59\u5bf9\u8c61\u7684\u67e5\u8be2\uff0c\u80fd\u66f4\u76f4\u63a5\u53d1\u73b0\u95ee\u9898\u3002\n<\/p>\n<p>\n\t\u6ce8\u610f\uff1a\u56e0\u4e3avjmap\u7684\u539f\u7406\uff0c\u53ea\u652f\u6301CMS\u548cParallelGC\uff0c\u4e0d\u652f\u6301G1.\n<\/p>\n<h2>\n\t\u4f7f\u7528\u8bf4\u660e<br \/>\n<\/h2>\n<p>\n\tmaven\u7f16\u8bd1\u540e\u5f97\u5230zip\u5305\uff0c\u89e3\u538b\u540e\u8fd0\u884c\u3002\n<\/p>\n<p>\n\t\u6ce8\u610f\uff1avjmap\u5728\u6267\u884c\u8fc7\u7a0b\u4e2d\uff0c\u4f1a\u5b8c\u5168\u505c\u6b62\u5e94\u7528\uff0c\u5fc5\u987b\u6458\u6d41\u91cf\u6267\u884c\uff01\uff01\uff01\uff01\n<\/p>\n<p>\n\t\u5fc5\u987b\u4e0e\u76ee\u6807JVM\u4f7f\u7528\u76f8\u540c\u7528\u6237\u8fd0\u884c\uff0c\u5982\u679c\u6267\u884c\u65f6\u4ecd\u7136\u6709\u6743\u9650\u9519\u8bef\uff0c\u6539\u7528root\u7528\u6237\u6267\u884c\u3002\n<\/p>\n<p>\n\t\u5982\u679c\u4f7f\u7528\u4e86kill -9 vjmap\u7684\u8fdb\u7a0b\u6765\u5f3a\u884c\u7ec8\u6b62vjmap\uff0c \u76ee\u6807java\u8fdb\u7a0b\u4f1a\u88ab\u5361\u4f4f\u4e0d\u518d\u5de5\u4f5c\uff08\u7528\u6b63\u5e38\u7684kill vjmap\u5219\u6ca1\u6709\u95ee\u9898\uff09\uff0c\u5fc5\u987b\u6267\u884c\u4e24\u6b21 kill -18 \u76ee\u6807\u8fdb\u7a0bPID\u6765\u91cd\u65b0\u5524\u9192\u76ee\u6807java\u8fdb\u7a0b\u3002\n<\/p>\n<h2>\n\t\u5e38\u7528\u6307\u4ee4<br \/>\n<\/h2>\n<pre class=\"brush:bash;\">\r\n\/\/ \u6253\u5370\u6574\u4e2a\u5806\u4e2d\u5bf9\u8c61\u7684\u7edf\u8ba1\u4fe1\u606f\uff0c\u6309\u5bf9\u8c61\u7684total size\u6392\u5e8f:\r\n.\/vjmap.sh -all PID &gt; \/tmp\/histo.log\r\n\r\n\/\/ \u6253\u5370\u8001\u5e74\u4ee3\u7684\u5bf9\u8c61\u7edf\u8ba1\u4fe1\u606f\uff0c\u6309\u5bf9\u8c61\u7684oldgen size\u6392\u5e8f\uff0c\u6682\u65f6\u53ea\u652f\u6301CMS:  \r\n.\/vjmap.sh -old PID &gt; \/tmp\/histo-old.log\r\n\r\n\/\/ \u6253\u5370Survivor\u533a\u7684\u5bf9\u8c61\u7edf\u8ba1\u4fe1\u606f\uff0c\u9ed8\u8ba4age&gt;=3: \r\n.\/vjmap.sh -sur PID &gt; \/tmp\/histo-sur.log\r\n\r\n\/\/ \u6253\u5370Survivor\u533a\u7684\u5bf9\u8c61\u7edf\u8ba1\u4fe1\u606f\uff0cage&gt;=10\r\n\/\/ \u5148\u589e\u5927\u664b\u5347\u9608\u503c-XX:MaxTenuringThreshold=xx, \u901a\u8fc7\u67e5\u8be2age\u8f83\u9ad8\u7684\u5bf9\u8c61\uff0c\u5373\u5fc5\u5b9a\u4f1a\u9003\u9038\u5230cms\u533a\u7684\u5bf9\u8c61\u3002\r\n.\/vjmap.sh -sur:minage=10 PID &gt; \/tmp\/histo-sur.log<\/pre>\n<p>\n\t\u5176\u4e2dPID\u4e3a\u76ee\u6807java\u8fdb\u7a0b\u7684\u8fdb\u7a0b\u53f7\u3002\n<\/p>\n<h2>\n\t\u8fc7\u6ee4\u5bf9\u8c61\u5927\u5c0f\uff0c\u4e0d\u663e\u793a\u8fc7\u5c0f\u7684\u5bf9\u8c61:<br \/>\n<\/h2>\n<pre class=\"brush:bash;\">\r\n\/\/ \u6309\u5bf9\u8c61\u7684total size\u8fdb\u884c\u8fc7\u6ee4\uff0c\u53ea\u6253\u5370\u5360\u7528\u8d85\u8fc71K\u7684\u6570\u636e\r\n.\/vjmap.sh -all:minsize=1024 PID &gt; \/tmp\/histo.log\r\n\r\n\/\/ \u6309\u5bf9\u8c61\u7684oldgen size\u8fdb\u884c\u8fc7\u6ee4\uff0c\u53ea\u6253\u5370OldGen\u5360\u7528\u8d85\u8fc71K\u7684\u6570\u636e\r\n.\/vjmap.sh -old:minsize=1024 PID &gt; \/tmp\/histo-old.log\r\n\r\n\/\/ \u6309\u5bf9\u8c61\u7684survivor size\u8fdb\u884c\u8fc7\u6ee4\uff0c\u53ea\u6253\u5370Survivor\u5360\u7528\u8d85\u8fc71K\u7684\u6570\u636e\r\n.\/vjmap.sh -sur:minsize=1024 PID &gt; \/tmp\/histo-sur.log<\/pre>\n<h2>\n\t\u6309class name\u6392\u5e8f\uff0c\u914d\u5408\u5927\u5c0f\u8fc7\u6ee4\u751f\u6210\u7528\u4e8e\u5b9a\u65f6\u6bd4\u8f83\u7684\u62a5\u8868:<code> <\/code><br \/>\n<\/h2>\n<pre class=\"brush:bash;\">\r\n.\/vjmap.sh -all:minsize=1024,byname PID &gt; \/tmp\/histo.log\r\n.\/vjmap.sh -old:minsize=1024,byname PID &gt; \/tmp\/histo-old.log\r\n.\/vjmap.sh -sur:minsize=1024,byname PID &gt; \/tmp\/histo-sur.log<\/pre>\n<h2>\n\tSurvivor\u533a\u5e74\u9f84\u5927\u4e8eN\u7684\u5bf9\u8c61\u7edf\u8ba1<br \/>\n<\/h2>\n<pre class=\"brush:plain;\">\r\nSurvivor Object Histogram:\r\n\r\n #num  #count     #bytes #Class description\r\n-----------------------------------------------------------------------------------\r\n   1:      37         1k io.netty.buffer.PoolThreadCache$MemoryRegionCache$Entry\r\n   2:       2         64 java.util.concurrent.locks.AbstractQueuedSynchronizer$Node\r\nTotal: 39\/    1k over age 2\r\n\r\nHeap traversal took 1.3 seconds.<\/pre>\n<h2>\n\t\u4fee\u6539\u8bb0\u5f55<br \/>\n<\/h2>\n<ul>\n<li>\n\t\t\u517c\u5bb9JDK8\n\t<\/li>\n<li>\n\t\t\u65b0\u529f\u80fd\uff1aSurvivor\u533a age\u5927\u4e8eN\u7684\u5bf9\u8c61\u7edf\u8ba1\n\t<\/li>\n<li>\n\t\t\u6027\u80fd\u63d0\u5347\uff1a\u76f4\u63a5\u8bbf\u95eeSurvivor\u6216OldGen\u533a\uff0c\u800c\u4e0d\u662f\u7528Heap Visitor\u56de\u8c03\u7684\u65b9\u5f0f\u8bbf\u95ee\u6574\u4e2aHeap\n\t<\/li>\n<li>\n\t\t\u65b0\u914d\u7f6e\u9879\uff1a\u6309\u5bf9\u8c61\u7684\u5927\u5c0f\u8fdb\u884c\u8fc7\u6ee4\uff0c\u4e0d\u663e\u793a\u8fc7\u5c0f\u7684\u5bf9\u8c61\n\t<\/li>\n<li>\n\t\t\u65b0\u914d\u7f6e\u9879\uff1a\u6309\u5bf9\u8c61\u7684\u540d\u79f0\u8fdb\u884c\u6392\u5e8f\uff0c\u7528\u4e8e\u751f\u6210\u5b9a\u65f6\u6bd4\u8f83\u7684\u62a5\u8868\n\t<\/li>\n<li>\n\t\t\u8f93\u51fa\u6539\u8fdb\uff1a\u62a5\u8868\u6570\u5b57\u7684\u5355\u4f4d\u5316(k,m,g)\u4e0e\u5bf9\u9f50\uff0cOldGen\u62a5\u8868\u9ed8\u8ba4\u6309\u5bf9\u8c61\u5728OldGen\u7684\u5927\u5c0f\u6392\u5e8f\n\t<\/li>\n<\/ul>\n<!-- <audio autoplay=\"autoplay\" height=\"100\" width=\"100\" hidden=\"true\"><source src=\"https:\/\/c.coka.la\/orAvPR.mp3\" type=\"audio\/mp3\"\/><\/audio><img decoding=\"async\" src=\"https:\/\/images.weserv.nl\/?url=https:\/\/ws3.sinaimg.cn\/large\/8fa5dcfcgy1g4em3rzar5j20ib089ae0.jpg\" alt=\"\u4e1a\u4f59\u8349\u516c\u4f17\u53f7\"\/> --><p><!-- <img decoding=\"async\" src=\"https:\/\/raw.githubusercontent.com\/xmt1139057136\/xttblog\/master\/8fa5dcfcgy1g4em3rzar5j20ib089ae0.jpg\" alt=\"\u4e1a\u4f59\u8349\u516c\u4f17\u53f7\"\/>--><img decoding=\"async\" src=\"https:\/\/saas.51autoparts.cn\/api\/admin\/sys-file\/oss\/file?fileName=84db51f8561e448f9a4fda2eff0811f9.jpg\" alt=\"\u4e1a\u4f59\u8349\u516c\u4f17\u53f7\"\/><\/p><p>\u6700\u540e\uff0c\u6b22\u8fce\u5173\u6ce8\u6211\u7684\u4e2a\u4eba\u5fae\u4fe1\u516c\u4f17\u53f7\uff1a\u4e1a\u4f59\u8349\uff08yyucao\uff09\uff01<b>\u53ef\u52a0\u4f5c\u8005\u5fae\u4fe1\u53f7\uff1a<font color=\"red\">xttblog2<\/font>\u3002\u5907\u6ce8\uff1a\u201c1\u201d\uff0c\u6dfb\u52a0\u535a\u4e3b\u5fae\u4fe1\u62c9\u4f60\u8fdb\u5fae\u4fe1\u7fa4\u3002\u5907\u6ce8\u9519\u8bef\u4e0d\u4f1a\u540c\u610f\u597d\u53cb\u7533\u8bf7\u3002<\/b>\u518d\u6b21\u611f\u8c22\u60a8\u7684\u5173\u6ce8\uff01\u540e\u7eed\u6709\u7cbe\u5f69\u5185\u5bb9\u4f1a\u7b2c\u4e00\u65f6\u95f4\u53d1\u7ed9\u60a8\uff01\u539f\u521b\u6587\u7ae0\u6295\u7a3f\u8bf7\u53d1\u9001\u81f3532009913@qq.com\u90ae\u7bb1\u3002\u5546\u52a1\u5408\u4f5c\u4e5f\u53ef\u6dfb\u52a0\u4f5c\u8005\u5fae\u4fe1\u8fdb\u884c\u8054\u7cfb\uff01<\/p><p>\u672c\u6587\u539f\u6587\u51fa\u5904\uff1a<a href=\"https:\/\/www.xttblog.com\">\u4e1a\u4f59\u8349<\/a>\uff1a &raquo; <a href=\"https:\/\/www.xttblog.com\/?p=2822\">\u552f\u54c1\u4f1a vjmap \u6559\u7a0b<\/a><\/p><!-- <div class=\"bd-reward-stl\"><button id=\"bdRewardBtn\"><span><\/span><\/button><\/div> -->","protected":false},"excerpt":{"rendered":"<p>vjmap \u662f\u552f\u54c1\u4f1a\u5f00\u6e90\u51fa\u6765\u7684 vjtools \u5de5\u5177\u96c6\u7684\u4e00\u4e2a\u7528\u6765\u6392\u67e5 java \u5185\u5b58\u6cc4\u6f0f\u7684\u5de5\u5177\u3002\u4e0e\u8fd1\u65e5\u5728 gi [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[5],"tags":[261,327,731,1613,263],"class_list":["post-2822","post","type-post","status-publish","format-standard","hentry","category-java","tag-java","tag-jvm","tag-jvm-sandbox","tag-substring"],"_links":{"self":[{"href":"https:\/\/www.xttblog.com\/index.php?rest_route=\/wp\/v2\/posts\/2822","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.xttblog.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.xttblog.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.xttblog.com\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.xttblog.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=2822"}],"version-history":[{"count":1,"href":"https:\/\/www.xttblog.com\/index.php?rest_route=\/wp\/v2\/posts\/2822\/revisions"}],"predecessor-version":[{"id":2823,"href":"https:\/\/www.xttblog.com\/index.php?rest_route=\/wp\/v2\/posts\/2822\/revisions\/2823"}],"wp:attachment":[{"href":"https:\/\/www.xttblog.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=2822"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.xttblog.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=2822"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.xttblog.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=2822"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}