{"id":3369,"date":"2018-11-15T15:50:11","date_gmt":"2018-11-15T07:50:11","guid":{"rendered":"http:\/\/www.xttblog.com\/?p=3369"},"modified":"2018-11-15T15:50:11","modified_gmt":"2018-11-15T07:50:11","slug":"%e6%b7%b1%e5%85%a5%e7%90%86%e8%a7%a3-java-lang-outofmemoryerror-out-of-swap-space-%e9%94%99%e8%af%af","status":"publish","type":"post","link":"https:\/\/www.xttblog.com\/?p=3369","title":{"rendered":"\u6df1\u5165\u7406\u89e3 java.lang.OutOfMemoryError: Out of swap space \u9519\u8bef"},"content":{"rendered":"<p>\n\t\u6700\u8fd1\u6211\u662f\u60f3\u5199\u4e00\u4e2a JVM \u7cfb\u5217\uff0c\u7136\u540e\u5168\u90e8\u90fd\u53d1\u8868\u5230\u516c\u4f17\u53f7\u91cc\uff0c\u5728\u516c\u4f17\u53f7\u91cc\u5f62\u6210\u4e00\u4e2a\u83dc\u5355\u3002\u65b9\u4fbf\u6211\u7684\u7c89\u4e1d\u9605\u8bfb\uff01\n<\/p>\n<p>\n\t\u8fd9\u5199\u8fd9\u7bc7\u6587\u7ae0\u4e4b\u524d\uff0c\u6211\u5728\u767e\u5ea6\u91cc\u641c\u7d22\u4e86\u4e00\u4e0b\u5173\u4e8e&nbsp;java.lang.OutOfMemoryError: Out of swap space \u95ee\u9898\u7684\u5185\u5bb9\uff0c\u7ed3\u679c\u4e0d\u80dc\u7406\u60f3\u3002\u57fa\u672c\u4e0a\u5f88\u5c11\u6709\u8bb2\u6e05\u695a\u7684\uff0c\u4e8e\u662f\u6211\u5c31\u8c37\u6b4c\uff0c\u603b\u7ed3\u4e86\u672c\u6587\u3002\n<\/p>\n<p>\n\tjava.lang.OutOfMemoryError: Out of swap space \u9519\u8bef\uff0c\u6839\u636e\u81ea\u5df1\u610f\u601d\uff0c\u6211\u4eec\u5dee\u4e0d\u591a\u4e5f\u80fd\u770b\u51fa\u6765\u662f\u4ea4\u6362\u7a7a\u95f4(swap space,\u865a\u62df\u5185\u5b58) \u4e0d\u8db3\u3002\n<\/p>\n<p>\n\t\u8be6\u7ec6\u7684\u8bf4\uff0c\u5c31\u662f\u8fd9\u4e2a\u9519\u8bef\u662f\u5f53\u865a\u62df\u673a\u5411\u672c\u5730\u64cd\u4f5c\u7cfb\u7edf\u7533\u8bf7\u5185\u5b58\u5931\u8d25\u65f6\u629b\u51fa\u7684\u3002\u8fd9\u548c\u4f60\u7528\u5b8c\u4e86\u5806\u6216\u8005\u6301\u4e45\u5316\u4e2d\u7684\u5185\u5b58\u7684\u60c5\u51b5\u6709\u4e9b\u4e0d\u540c\u3002\u8fd9\u4e2a\u9519\u8bef\u901a\u5e38\u662f\u5728\u4f60\u7684\u7a0b\u5e8f\u5df2\u7ecf\u903c\u8fd1\u5e73\u53f0\u9650\u5236\u7684\u65f6\u5019\u4ea7\u751f\u7684\u3002\u8fd9\u4e2a\u4fe1\u606f\u544a\u8bc9\u4f60\u7684\u662f\uff0c\u4f60\u53ef\u80fd\u5df2\u7ecf\u7528\u5149\u4e86\u7269\u7406\u5185\u5b58\u4ee5\u53ca\u865a\u62df\u5185\u5b58\u4e86\u3002\u7531\u4e8e\u865a\u62df\u5185\u5b58\u901a\u5e38\u662f\u7528\u78c1\u76d8\u4f5c\u4e3a\u4ea4\u6362\u5206\u533a\uff0c\u56e0\u6b64\u4f60\u6700\u5148\u60f3\u5230\u7684\u89e3\u51b3\u65b9\u6cd5\u53ef\u80fd\u662f\u5148\u589e\u52a0\u4ea4\u6362\u5206\u533a\u7684\u5927\u5c0f\u3002\u4e0d\u8fc7\u6211\u4ece\u6ca1\u89c1\u8fc7\u4e00\u4e2a\u7a0b\u5e8f\u5728\u9891\u7e41\u8fdb\u884c\u5185\u5b58\u4ea4\u6362\u8fd8\u80fd\u6b63\u5e38\u8fd0\u884c\u7684\uff0c\u6240\u4ee5\u8fd9\u4e2a\u65b9\u6cd5\u53ef\u80fd\u4e0d\u4f1a\u8d77\u5230\u4ec0\u4e48\u4f5c\u7528\u3002\n<\/p>\n<p>\n\t\u5728 JVM \u542f\u52a8\u7684\u65f6\u5019\uff0c\u6211\u4eec\u53ef\u4ee5\u901a\u8fc7 -Xmx \u7b49\u53c2\u6570\u6765\u9650\u5236 JVM \u7684\u6700\u5927\u5185\u5b58\u3002\u5f53 JVM&nbsp;\u4f7f\u7528\u7684\u5185\u5b58\u603b\u91cf\u8d85\u8fc7\u53ef\u7528\u7684\u7269\u7406\u5185\u5b58\u65f6\uff0c\u64cd\u4f5c\u7cfb\u7edf\u5c31\u4f1a\u7528\u5230\u865a\u62df\u5185\u5b58\u3002\n<\/p>\n<p>\n\t<img decoding=\"async\" alt=\"java.lang.OutOfMemoryError: Out of swap space\" src=\"https:\/\/raw.githubusercontent.com\/xmt1139057136\/xttblog\/master\/out-of-swap-space.png\" style=\"width: 725px;height: 239px\" \/>\n<\/p>\n<p>\n\t\u770b\u8fc7\u524d\u9762\u6587\u7ae0\u7684\u4e5f\u90fd\u77e5\u9053\uff0c\u6211\u4e00\u76f4\u5728\u5f3a\u8c03\u4efb\u4f55 OutOfMemoryError \u9519\u8bef\uff0c\u591a\u6570\u90fd\u662f\u4f60\u7684\u7a0b\u5e8f\u5f15\u8d77\u7684\u3002\u6240\u4ee5\uff0c\u8fd9\u7c7b\u95ee\u9898\u66f4\u591a\u7684\u53ef\u80fd\u662f\u5e94\u7528\u7a0b\u5e8f\u7684\u672c\u5730\u5185\u5b58\u6cc4\u6f0f(native leak)\u5f15\u8d77\u7684\u3002\n<\/p>\n<p>\n\t\u60f3\u589e\u52a0\u865a\u62df\u5185\u5b58(swap space) \u7684\u5927\u5c0f\u7684\u8bdd\uff0c\u5f88\u7b80\u5355\u3002\u6bd4\u5982\u6267\u884c\u4e0b\u9762\u7684\u547d\u4ee4\uff1a\n<\/p>\n<pre class=\"brush:bash;\">\r\nswapoff -a \r\ndd if=\/dev\/zero of=swapfile bs=1024 count=655360\r\nmkswap swapfile\r\nswapon swapfile<\/pre>\n<p>\n\t\u8fd9\u6bb5\u547d\u4ee4\u521b\u5efa\u4e86\u4e00\u4e2a\u5927\u5c0f\u4e3a 640MB \u7684 swapfile(\u4ea4\u6362\u6587\u4ef6) \u5e76\u542f\u7528\u8be5\u6587\u4ef6\u3002\n<\/p>\n<p>\n\t\u5982\u679c\u901a\u8fc7\u589e\u52a0\u4e86\u4f60\u7684\u865a\u62df\u5185\u5b58\u5927\u5c0f\u8fd8\u662f\u4e0d\u80fd\u89e3\u51b3\u4f60\u7684\u95ee\u9898\uff0c\u5efa\u8bae\u4f60\u6309\u7167\u6211\u7684\u7b2c\u4e00\u7bc7\u6587\u7ae0\u300a<a href=\"https:\/\/www.xttblog.com\/?p=3345\" title=\"\u4e3a\u4ec0\u4e48\u4f1a\u4ea7\u751f java.lang.OutOfMemoryError: Java heap space \u9519\u8bef\u4ee5\u53ca\u5982\u4f55\u89e3\u51b3\uff1f - \u4e1a\u4f59\u8349\">\u4e3a\u4ec0\u4e48\u4f1a\u4ea7\u751f java.lang.OutOfMemoryError: Java heap space \u9519\u8bef\u4ee5\u53ca\u5982\u4f55\u89e3\u51b3\uff1f<\/a>\u300b\u4e2d\u7684\u6392\u67e5\u6b65\u9aa4\u6392\u67e5\u4f60\u7684\u7a0b\u5e8f\u3002\n<\/p>\n<p>\n\t\u5f53\u7136\u5982\u679c\u4f60\u7528\u7684 JDK \u7248\u672c\u8fc7\u4f4e\uff0c\u6211\u5efa\u8bae\u4f60\u5347\u7ea7\u5b83\u4eec\u3002\u56e0\u4e3a\u4f4e\u7248\u672c\u7684 JDK \u4e2d\u6709\u5f88\u591a\u5bf9\u5e94\u7684&nbsp;Out of swap space bug \u5b58\u5728\uff01\n<\/p>\n<h2>\n\t\u53c2\u8003\u8d44\u6599<br \/>\n<\/h2>\n<ul>\n<li>\n\t\t<a href=\"https:\/\/plumbr.io\/outofmemoryerror\/out-of-swap-space\" name=\"java.lang.OutOfMemoryError:Out of swap space?\" target=\"_blank\" title=\"java.lang.OutOfMemoryError:Out of swap space?\">java.lang.OutOfMemoryError:Out of swap space?<\/a>\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=3369\">\u6df1\u5165\u7406\u89e3 java.lang.OutOfMemoryError: Out of swap space \u9519\u8bef<\/a><\/p><!-- <div class=\"bd-reward-stl\"><button id=\"bdRewardBtn\"><span><\/span><\/button><\/div> -->","protected":false},"excerpt":{"rendered":"<p>\u6700\u8fd1\u6211\u662f\u60f3\u5199\u4e00\u4e2a JVM \u7cfb\u5217\uff0c\u7136\u540e\u5168\u90e8\u90fd\u53d1\u8868\u5230\u516c\u4f17\u53f7\u91cc\uff0c\u5728\u516c\u4f17\u53f7\u91cc\u5f62\u6210\u4e00\u4e2a\u83dc\u5355\u3002\u65b9\u4fbf\u6211\u7684\u7c89\u4e1d\u9605\u8bfb\uff01 \u8fd9\u5199\u8fd9\u7bc7 [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[5,6],"tags":[261,731,1647,601,314],"class_list":["post-3369","post","type-post","status-publish","format-standard","hentry","category-java","category-yyzt","tag-java","tag-jvm","tag-outofmemoryerror","tag-taobaojvm"],"_links":{"self":[{"href":"https:\/\/www.xttblog.com\/index.php?rest_route=\/wp\/v2\/posts\/3369","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=3369"}],"version-history":[{"count":1,"href":"https:\/\/www.xttblog.com\/index.php?rest_route=\/wp\/v2\/posts\/3369\/revisions"}],"predecessor-version":[{"id":3370,"href":"https:\/\/www.xttblog.com\/index.php?rest_route=\/wp\/v2\/posts\/3369\/revisions\/3370"}],"wp:attachment":[{"href":"https:\/\/www.xttblog.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=3369"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.xttblog.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=3369"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.xttblog.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=3369"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}