{"id":1919,"date":"2019-09-05T18:59:21","date_gmt":"2019-09-05T10:59:21","guid":{"rendered":"https:\/\/coderbee.net\/?p=1919"},"modified":"2019-09-05T19:01:40","modified_gmt":"2019-09-05T11:01:40","slug":"%e5%ae%b9%e5%99%a8%e4%b8%8b-xxheapdumponoutofmemoryerror-%e6%9c%aa%e7%94%9f%e6%88%90-dump-%e6%96%87%e4%bb%b6%e7%9a%84%e9%97%ae%e9%a2%98","status":"publish","type":"post","link":"https:\/\/coderbee.net\/index.php\/jvm\/20190905\/1919","title":{"rendered":"\u5bb9\u5668\u4e0b -XX:+HeapDumpOnOutOfMemoryError \u672a\u751f\u6210 dump \u6587\u4ef6\u7684\u95ee\u9898"},"content":{"rendered":"<p>JVM \u7684\u542f\u52a8\u547d\u4ee4\u4e00\u822c\u90fd\u4f1a\u52a0\u4e0a\u53c2\u6570 <code>-XX:+HeapDumpOnOutOfMemoryError=\/path\/to\/save\/dump.hprof<\/code>\uff0c\u7528\u4e8e\u5728 JVM \u53d1\u751f OOM \u65f6\u81ea\u52a8\u751f\u6210\u5185\u5b58 dump \u6587\u4ef6\u3002<\/p>\n<p>\u5e94\u7528\u5728\u751f\u4ea7\u73af\u5883\u662f\u8fd0\u884c\u5728 Docker \u5bb9\u5668\u91cc\u3001\u7531 K8S \u8d1f\u8d23\u7ba1\u7406\u5bb9\u5668\u3002<\/p>\n<p>\u4f46\u662f\u6709\u7684\u5e94\u7528\u53d1\u751f OOM \u65f6\uff0c\u5728 <code>\/path\/to\/save\/dump.hprof<\/code> \u8def\u5f84\u4e0b\u5e76\u6ca1\u6709\u751f\u6210\u5bf9\u5e94\u7684 dump \u6587\u4ef6\u3002<\/p>\n<p>\u4f18\u79c0\u7684\u8fd0\u7ef4\u540c\u4e8b\u5c0f\u4f0d\u5728\u6d4b\u8bd5\u73af\u5883\u8fdb\u884c\u4e86\u5404\u79cd\u6d4b\u8bd5\uff0c\u5f97\u51fa\u4ee5\u4e0b\u4e24\u79cd\u60c5\u51b5\u6ca1\u6cd5\u751f\u4ea7\u6587\u4ef6\uff1a<br \/>\n1. <code>\/path\/to\/save\/<\/code> \u5982\u679c\u4e2d\u95f4\u5c42\u7684\u76ee\u5f55\u6ca1\u6709\u63d0\u524d\u5efa\u597d\uff0c\u662f\u6ca1\u6cd5\u751f\u6210 dump \u6587\u4ef6\u7684\u3002<br \/>\n2. \u5806\u5916\u5185\u5b58\u4e0d\u8db3 800M \u65f6\uff0c\u4e5f\u6ca1\u6cd5\u751f\u6210 dump \u6587\u4ef6\u3002<\/p>\n<p>\u7b2c1\u70b9\u6ca1\u5565\u95ee\u9898\uff0c\u6587\u4ef6\u6240\u5728\u7684\u76ee\u5f55\u6ca1\u6709\u63d0\u524d\u5efa\u597d\u662f\u4f1a\u62a5 <code>java.io.FileNotFoundException<\/code> \u5f02\u5e38\u7684\u3002<\/p>\n<p>\u7b2c2\u70b9\u5176\u5b9e\u662f\u56e0\u4e3a JVM \u8fd0\u884c\u5728\u5bb9\u5668\u91cc\uff0c\u5bb9\u5668\u5141\u8bb8\u4f7f\u7528\u7684\u5185\u5b58\u662f\u6709\u4e0a\u9650\u7684\uff0c\u6bd4\u5982\u5206\u914d\u7ed9\u5bb9\u5668\u7684\u662f 4G \u5185\u5b58\uff0cJVM \u5806\u5360\u7528 80%\uff0c\u90a3\u4e48\u5806\u5916\u5185\u5b58\u5c31\u53ea\u80fd\u5360\u7528 20% \u5373 800M\u3002<\/p>\n<p>\u53d1\u751f OOM \u65f6\uff0cJVM \u5360\u7528\u4e86 3.2G\uff1b\u5bf9\u4e8e\u5806\u5916\u5185\u5b58\uff0c\u7ebf\u7a0b\u3001JVM\u81ea\u8eab\u3001\u5e94\u7528\u7533\u8bf7\u7684\u672c\u5730\u5185\u5b58\u7b49\u90fd\u8981\u5728\u8fd9\u91cc\u5206\u914d\uff0cOOM dump \u4e5f\u9700\u8981\u5229\u7528\u5806\u5916\u5185\u5b58\uff0c\u5bb9\u5668\u4f7f\u7528\u7684\u603b\u5185\u5b58\u8fbe\u5230 4G \u5185\u5b58\u4e0a\u9650\u65f6\uff0c\u89e6\u53d1\u7cfb\u7edf\u7684 oomkiller \u673a\u5236\u628a\u5bb9\u5668\u8fdb\u7a0b\u6740\u6b7b\u3002<\/p>\n<p>\u8fd9\u5e26\u6765\u4e00\u4e2a\u5c0f\u95ee\u9898\uff1a\u5982\u679c\u8981\u4fdd\u8bc1 JVM OOM \u81ea\u52a8 dump \u673a\u5236\u80fd\u987a\u5229\u6267\u884c\uff0c\u6211\u4eec\u5c31\u9700\u8981\u5728\u5bb9\u5668\u91cc\u9884\u7559\u51fa\u8db3\u591f\u7684\u5806\u5916\u5185\u5b58\uff0c\u6bcf\u4e2a\u5bb9\u5668\u90fd\u5f97\u8003\u8651\u9884\u7559\uff0c\u8fd9\u5c31\u5e26\u6765\u5185\u5b58\u5229\u7528\u7387\u7684\u95ee\u9898\u4e86\u3002\u5982\u679c JVM \u76f4\u63a5\u8fd0\u884c\u5728\u5bbf\u4e3b\u64cd\u4f5c\u7cfb\u7edf\uff0c\u6ca1\u6709\u5bb9\u5668\u7684\u9650\u5236\uff0c\u80fd\u7533\u8bf7\u7684\u5806\u5916\u5185\u5b58\u662f\u53d7\u9650\u4e8e\u7cfb\u7edf\u80fd\u5206\u914d\u7684\u5185\u5b58\u7684\uff0c\u4e0d\u540c\u5e94\u7528\u7684 JVM \u53ef\u5171\u4eab\u8fd9\u4e2a\u53ef\u5206\u914d\u5185\u5b58\u7a7a\u95f4\u3002<\/p>\n<hr \/>\n<p>\u6b22\u8fce\u5173\u6ce8\u6211\u7684\u5fae\u4fe1\u516c\u4f17\u53f7: <strong>coderbee\u7b14\u8bb0<\/strong>\uff0c\u53ef\u4ee5\u66f4\u53ca\u65f6\u56de\u590d\u4f60\u7684\u8ba8\u8bba\u3002<br \/>\n<img loading=\"lazy\" decoding=\"async\" width=\"258\" height=\"258\" src=\"https:\/\/coderbee.net\/wp-content\/uploads\/2019\/01\/coderbee-note.jpg\" class=\"alignnone size-full wp-image-1707\" \/><\/p>\n","protected":false},"excerpt":{"rendered":"<p>JVM \u7684\u542f\u52a8\u547d\u4ee4\u4e00\u822c\u90fd\u4f1a\u52a0\u4e0a\u53c2\u6570 -XX:+HeapDumpOnOutOfMe &hellip; <a href=\"https:\/\/coderbee.net\/index.php\/jvm\/20190905\/1919\">\u7ee7\u7eed\u9605\u8bfb <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[96],"tags":[320,321],"_links":{"self":[{"href":"https:\/\/coderbee.net\/index.php\/wp-json\/wp\/v2\/posts\/1919"}],"collection":[{"href":"https:\/\/coderbee.net\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/coderbee.net\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/coderbee.net\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/coderbee.net\/index.php\/wp-json\/wp\/v2\/comments?post=1919"}],"version-history":[{"count":4,"href":"https:\/\/coderbee.net\/index.php\/wp-json\/wp\/v2\/posts\/1919\/revisions"}],"predecessor-version":[{"id":1923,"href":"https:\/\/coderbee.net\/index.php\/wp-json\/wp\/v2\/posts\/1919\/revisions\/1923"}],"wp:attachment":[{"href":"https:\/\/coderbee.net\/index.php\/wp-json\/wp\/v2\/media?parent=1919"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/coderbee.net\/index.php\/wp-json\/wp\/v2\/categories?post=1919"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/coderbee.net\/index.php\/wp-json\/wp\/v2\/tags?post=1919"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}