{"id":2826,"date":"2018-06-02T12:28:08","date_gmt":"2018-06-02T04:28:08","guid":{"rendered":"http:\/\/www.xttblog.com\/?p=2826"},"modified":"2018-06-02T12:28:08","modified_gmt":"2018-06-02T04:28:08","slug":"%e5%94%af%e5%93%81%e4%bc%9a-vjdump-%e6%95%99%e7%a8%8b","status":"publish","type":"post","link":"https:\/\/www.xttblog.com\/?p=2826","title":{"rendered":"\u552f\u54c1\u4f1a vjdump \u6559\u7a0b"},"content":{"rendered":"<p>\n\tVJDump\u662f\u7ebf\u4e0aJVM\u6570\u636e\u7d27\u6025\u6536\u96c6\u811a\u672c\u3002\n<\/p>\n<p>\n\t\u5b83\u53ef\u4ee5\u5728\u7d27\u6025\u573a\u666f\u4e0b\uff08\u6bd4\u5982\u9a6c\u4e0a\u8981\u5bf9\u8fdb\u7a0b\u8fdb\u884c\u91cd\u542f\uff09\uff0c\u4e00\u952e\u6536\u96c6jstack\u3001jmap\u4ee5\u53caGC\u65e5\u5fd7\u7b49\u76f8\u5173\u4fe1\u606f\uff0c\u5e76\u4ee5zip\u5305\u4fdd\u5b58(\u9ed8\u8ba4\u5728\u76ee\u5f55<code>\/tmp\/vjtools\/vjdump<\/code>\u4e0b)\uff0c\u4fdd\u8bc1\u5728\u7d27\u6025\u60c5\u51b5\u4e0b\u4ecd\u80fd\u6536\u96c6\u8db3\u591f\u7684\u95ee\u9898\u6392\u67e5\u4fe1\u606f\uff0c\u51cf\u8f7b\u8fd0\u7ef4\u56e2\u961f\u7684\u5de5\u4f5c\u91cf\uff0c\u4ee5\u53ca\u4e0e\u5f00\u53d1\u56e2\u961f\u7684\u6c9f\u901a\u6210\u672c\u3002\n<\/p>\n<p>\n\t\u6536\u96c6\u6570\u636e\u5305\u62ec\uff1a\n<\/p>\n<ul>\n<li>\n\t\tJVM\u542f\u52a8\u53c2\u6570\u53ca\u547d\u4ee4\u884c\u53c2\u6570:&nbsp;<code>jinfo -flags $PID<\/code>\n\t<\/li>\n<li>\n\t\tthread dump\u6570\u636e\uff1a<code>jstack -l $PID<\/code>\n\t<\/li>\n<li>\n\t\tvjtop JVM\u6982\u51b5\u53ca\u7e41\u5fd9\u7ebf\u7a0b\uff1a<code>vjtop.sh -n 1 -d 3 $PID<\/code>&nbsp;(\u9700\u8981\u5c06vjtop.sh \u52a0\u5165\u7528\u6237\u7684PATH\u53d8\u91cf\u4e2d)\n\t<\/li>\n<li>\n\t\tjmap histo \u5806\u5bf9\u8c61\u7edf\u8ba1\u6570\u636e\uff1a<code>jmap -histo $PID<\/code>&nbsp;&amp;&nbsp;<code>jmap -histo:live $PID<\/code>\n\t<\/li>\n<li>\n\t\tGC\u65e5\u5fd7(\u5982\u679cJVM\u6709\u8bbe\u5b9aGC\u65e5\u5fd7\u8f93\u51fa)\n\t<\/li>\n<li>\n\t\theap dump\u6570\u636e\uff08\u9700\u6307\u5b9a&#8211;liveheap\u5f00\u542f\uff09\uff1a<code>jmap -dump:live,format=b,file=${DUMP_FILE} $PID<\/code>\n\t<\/li>\n<\/ul>\n<p>\n\t\u4e0b\u8f7d\u5730\u5740\uff1a<a href=\"https:\/\/raw.githubusercontent.com\/vipshop\/vjtools\/master\/vjdump\/vjdump.sh\" rel=\"nofollow\">vjdump.sh<\/a>\n<\/p>\n<h2>\n\t\u5165\u95e8\u6559\u7a0b<br \/>\n<\/h2>\n<p>\n\t\u4ee5\u76ee\u6807JVM\u76f8\u540c\u7528\u6237\u6216root\u7528\u6237\u8fd0\u884c\u811a\u672c\uff1a\n<\/p>\n<pre class=\"brush:bash;\">\r\n# \u5bf9\u6307\u5b9a\u7684\u8fdb\u7a0bPID\u8fdb\u884c\u6025\u8bca\r\nvjdump.sh $pid\r\n\r\n# \u989d\u5916\u6536\u96c6heap dump\u4fe1\u606f\uff08jmap -dump:live\u7684\u4fe1\u606f\uff09\r\nvjdump.sh --liveheap $pid<\/pre>\n<p>\n\t\u5728\u6536\u96c6\u8fc7\u7a0b\u4e2d\uff0c\u67d0\u4e9b\u547d\u4ee4\u5982<code>jmap -histo:live $PID<\/code>&nbsp;\u4f1a\u9020\u6210JVM\u505c\u987f\uff0c\u56e0\u6b64\u4ec5\u7528\u4e8e\u7d27\u6025\u60c5\u51b5\u6216\u5df2\u6458\u6d41\u91cf\u7684\u60c5\u51b5\u3002\u4e3a\u4e86\u907f\u514d\u8fde\u7eed\u505c\u987f\uff0c\u5728\u6bcf\u6761\u4f1a\u9020\u6210\u505c\u987f\u7684\u6536\u96c6\u6307\u4ee4\u4e4b\u95f4\uff0c\u9ed8\u8ba4\u63d2\u5165\u4e861\u79d2\u7684\u6267\u884c\u95f4\u9694\u3002<\/p>\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=2826\">\u552f\u54c1\u4f1a vjdump \u6559\u7a0b<\/a><\/p><!-- <div class=\"bd-reward-stl\"><button id=\"bdRewardBtn\"><span><\/span><\/button><\/div> -->","protected":false},"excerpt":{"rendered":"<p>VJDump\u662f\u7ebf\u4e0aJVM\u6570\u636e\u7d27\u6025\u6536\u96c6\u811a\u672c\u3002 \u5b83\u53ef\u4ee5\u5728\u7d27\u6025\u573a\u666f\u4e0b\uff08\u6bd4\u5982\u9a6c\u4e0a\u8981\u5bf9\u8fdb\u7a0b\u8fdb\u884c\u91cd\u542f\uff09\uff0c\u4e00\u952e\u6536\u96c6jstac [&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":[731,1613,314,1532,1113],"class_list":["post-2826","post","type-post","status-publish","format-standard","hentry","category-java","tag-jvm","tag-jvm-sandbox","tag-taobaojvm","tag-1532","tag-1113"],"_links":{"self":[{"href":"https:\/\/www.xttblog.com\/index.php?rest_route=\/wp\/v2\/posts\/2826","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=2826"}],"version-history":[{"count":1,"href":"https:\/\/www.xttblog.com\/index.php?rest_route=\/wp\/v2\/posts\/2826\/revisions"}],"predecessor-version":[{"id":2827,"href":"https:\/\/www.xttblog.com\/index.php?rest_route=\/wp\/v2\/posts\/2826\/revisions\/2827"}],"wp:attachment":[{"href":"https:\/\/www.xttblog.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=2826"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.xttblog.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=2826"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.xttblog.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=2826"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}