{"id":3347,"date":"2018-11-12T11:50:05","date_gmt":"2018-11-12T03:50:05","guid":{"rendered":"http:\/\/www.xttblog.com\/?p=3347"},"modified":"2018-11-12T11:51:32","modified_gmt":"2018-11-12T03:51:32","slug":"%e8%af%a6%e8%a7%a3-java-lang-outofmemoryerror-gc-overhead-limit-exceeded-%e9%94%99%e8%af%af%ef%bc%81","status":"publish","type":"post","link":"https:\/\/www.xttblog.com\/?p=3347","title":{"rendered":"\u8be6\u89e3 java.lang.OutOfMemoryError: GC overhead limit exceeded \u9519\u8bef\uff01"},"content":{"rendered":"<p>\n\tjava \u4e2d\u6709\u51e0\u4e2a\u96be\u5144\u96be\u5f1f\uff0c\u6bd4\u5982\u6211\u6628\u5929\u5199\u7684 java.lang.OutOfMemoryError: Java heap space \u548c\u4eca\u5929\u8981\u5199\u7684 java.lang.OutOfMemoryError: GC overhead limit exceeded \u7b49\u3002\u8981\u641e\u6e05\u8fd9\u4e9b\u77e5\u8bc6\uff0c\u5c31\u9700\u8981\u6df1\u5165\u7684\u7406\u89e3 JVM \u5e95\u5c42\u539f\u7406\u548c\u5b9e\u73b0\u673a\u5236\u3002\n<\/p>\n<p>\n\t\u90a3\u4e48\u6211\u4eec\u4eca\u5929\u5c31\u5177\u4f53\u6765\u8bf4\u8bf4 java.lang.OutOfMemoryError: GC overhead limit exceeded \u5427\uff01\n<\/p>\n<p>\n\t\u6211\u4eec\u90fd\u77e5\u9053\uff0cJava \u8bed\u8a00\u7684\u4e00\u5927\u4f18\u52bf\u5c31\u662f\u5185\u5b58\u7ba1\u7406\uff0c\u4e5f\u5c31\u662f\u5783\u573e\u56de\u6536\u673a\u5236\u3002\u76f8\u6bd4\u5176\u4ed6\u8bed\u8a00\uff0c\u5982\uff1aC++\u7b49\uff0c\u5b83\u4eec\u8fd9\u4e9b\u8bed\u8a00\u4e2d\u5e76\u6ca1\u6709\u81ea\u52a8\u5185\u5b58\u56de\u6536\u673a\u5236, \u9700\u8981\u7a0b\u5e8f\u5458\u624b\u5de5\u7f16\u5199\u4ee3\u7801\u6765\u8fdb\u884c\u5185\u5b58\u5206\u914d\u548c\u91ca\u653e, \u4ee5\u91cd\u590d\u5229\u7528\u5806\u5185\u5b58\u3002\n<\/p>\n<p>\n\t\u4e5f\u6b63\u662f\u56e0\u4e3a Java \u8bed\u8a00\u6709\u81ea\u52a8\u5783\u573e\u56de\u6536\u673a\u5236\uff0c\u6240\u4ee5\u4e00\u4e9b\u7a0b\u5e8f\u5458\u5728\u4f7f\u7528\u4e0d\u5f53\u7684\u60c5\u51b5\u4e0b\uff0c\u4f1a\u53d1\u751f\u4e00\u7cfb\u5217\u4f60\u610f\u60f3\u4e0d\u5230\u7684&nbsp;OutOfMemoryError\u3002\u5173\u4e8e&nbsp;OutOfMemoryError \u9519\u8bef\uff0c\u76ee\u524d\u4e00\u5171\u6709 8 \u79cd\uff0c\u6211\u4eec\u4e00\u4e00\u7684\u6765\u641e\u5b9a\u5b83\u4eec\uff01\n<\/p>\n<p>\n\tjava.lang.OutOfMemoryError: GC overhead limit exceeded \u8fd9\u79cd\u60c5\u51b5\u53d1\u751f\u7684\u539f\u56e0\u662f\u7a0b\u5e8f\u57fa\u672c\u4e0a\u8017\u5c3d\u4e86\u6240\u6709\u7684\u53ef\u7528\u5185\u5b58, GC \u4e5f\u6e05\u7406\u4e0d\u4e86\u3002\n<\/p>\n<p>\n\t\u66f4\u51c6\u786e\u7684\u8bf4\u6cd5\u5e94\u8be5\u662f\uff1a\u6267\u884c\u5783\u573e\u6536\u96c6\u7684\u65f6\u95f4\u6bd4\u4f8b\u592a\u5927\uff0c\u6709\u6548\u7684\u8fd0\u7b97\u91cf\u592a\u5c0f\u3002\u9ed8\u8ba4\u60c5\u51b5\u4e0b\uff0c\u5982\u679cGC\u82b1\u8d39\u7684\u65f6\u95f4\u8d85\u8fc7 98%\uff0c\u5e76\u4e14GC \u56de\u6536\u7684\u5185\u5b58\u5c11\u4e8e 2%\uff0cJVM \u5c31\u4f1a\u629b\u51fa\u8fd9\u4e2a\u9519\u8bef\u3002\n<\/p>\n<p>\n\t<img decoding=\"async\" alt=\"Time used by GC pauses\" src=\"https:\/\/raw.githubusercontent.com\/xmt1139057136\/xttblog\/master\/gc-overhead-limit-exceeded.png\" style=\"width: 711px;height: 227px\" \/>\n<\/p>\n<p>\n\tjava.lang.OutOfMemoryError: GC overhead limit exceeded \u9519\u8bef\u53ea\u5728\u8fde\u7eed\u591a\u6b21 GC \u90fd\u53ea\u56de\u6536\u4e86\u4e0d\u52302%\u7684\u6781\u7aef\u60c5\u51b5\u4e0b\u624d\u4f1a\u629b\u51fa\u3002\u5047\u5982\u4e0d\u629b\u51fa GC overhead limit \u9519\u8bef\u4f1a\u53d1\u751f\u4ec0\u4e48\u60c5\u51b5\u5462? \u90a3\u5c31\u662f GC \u6e05\u7406\u7684\u8fd9\u4e48\u70b9\u5185\u5b58\u5f88\u5feb\u4f1a\u518d\u6b21\u586b\u6ee1\uff0c\u8feb\u4f7f GC \u518d\u6b21\u6267\u884c\u3002\u8fd9\u6837\u5c31\u5f62\u6210\u6076\u6027\u5faa\u73af\uff0cCPU \u4f7f\u7528\u7387\u4e00\u76f4\u662f 100%\uff0c\u800c GC \u5374\u6ca1\u6709\u4efb\u4f55\u6210\u679c\u3002\u7cfb\u7edf\u7528\u6237\u5c31\u4f1a\u770b\u5230\u7cfb\u7edf\u5361\u6b7b\u3002\u4ee5\u524d\u53ea\u9700\u8981\u51e0\u6beb\u79d2\u7684\u64cd\u4f5c\uff0c\u73b0\u5728\u9700\u8981\u597d\u51e0\u5206\u949f\u624d\u80fd\u5b8c\u6210\u3002\n<\/p>\n<p>\n\t\u4e0b\u9762\u6211\u4eec\u6765\u770b\u4e00\u4e2a\u4ea7\u751f&ldquo;GC overhead limit exceeded&rdquo; \u9519\u8bef\u7684\u4f8b\u5b50\uff1a\n<\/p>\n<pre class=\"brush:java;\">\r\npackage com.xttblog.rtime;\r\nimport java.util.Map;\r\nimport java.util.Random;\r\npublic class TestWrapper {\r\n    public static void main(String args[]) throws Exception {\r\n        Map map = System.getProperties();\r\n        Random r = new Random();\r\n        while (true) {\r\n            map.put(r.nextInt(), &quot;value&quot;);\r\n        }\r\n    }\r\n}<\/pre>\n<p>\n\t\u4e3a\u4e86\u80fd\u591f\u66f4\u5feb\u7684\u770b\u5230\u6548\u679c\uff0c\u6211\u4eec\u53ef\u4ee5\u8bbe\u7f6e\u4e00\u4e0b JVM \u7684\u53c2\u6570\uff1a\n<\/p>\n<pre class=\"brush:java;\">\r\njava -Xmx12m -XX:+UseParallelGC TestWrapper<\/pre>\n<p>\n\t\u9700\u8981\u6ce8\u610f\u7684\u662f\uff0c\u4e0d\u540c\u7684 GC \u7b97\u6cd5\u3002\u4ea7\u751f\u7684\u9519\u8bef\u4fe1\u606f\u4e5f\u4e0d\u76f8\u540c\uff0c\u6709\u7684\u53ef\u80fd\u4f1a\u4ea7\u751f java.lang.OutOfMemoryError: Java heap space \u9519\u8bef\u3002\n<\/p>\n<p>\n\t\u5173\u4e8e\u5177\u4f53\u7684 GC \u7b97\u6cd5\uff0c\u6211\u7ed9\u5927\u5bb6\u4e00\u5f20\u5173\u4e8e Java8 GC \u7b97\u6cd5\u7684\u5217\u8868\uff0c\u6211\u540e\u9762\u518d\u5177\u4f53\u7684\u5199\u6587\u7ae0\u6765\u8bb2\u3002\n<\/p>\n<p>\n\t<img decoding=\"async\" alt=\"Java8 GC \u7b97\u6cd5\" src=\"https:\/\/raw.githubusercontent.com\/xmt1139057136\/xttblog\/master\/jvm-gc-java8.png\" style=\"width: 968px;height: 475px\" \/>\n<\/p>\n<p>\n\t\u6211\u4eec\u5728\u8bf4\u8bf4\u4e0a\u9762\u4ea7\u751f OutOfMemoryError \u9519\u8bef\u7684\u4ee3\u7801\u5427\u3002Map \u5728\u8fdb\u884c rehash \u65f6\u629b\u51fa\u4e86 java.lang.OutOfMemoryError \u9519\u8bef\u6d88\u606f\u3002\u5982\u679c\u4f7f\u7528\u5176\u4ed6\u5783\u573e\u6536\u96c6\u7b97\u6cd5\uff0c\u6bd4\u5982 -XX:+UseConcMarkSweepGC\uff0c\u6216\u8005 -XX:+UseG1GC\uff0c\u9519\u8bef\u5c06\u88ab\u9ed8\u8ba4\u7684 exception handler \u6240\u6355\u83b7\uff0c\u4f46\u662f\u6ca1\u6709 stacktrace \u4fe1\u606f\uff0c\u56e0\u4e3a\u5728\u521b\u5efa Exception \u65f6\u6ca1\u529e\u6cd5\u586b\u5145 stacktrace \u4fe1\u606f\u3002\n<\/p>\n<p>\n\t\u518d\u6bd4\u5982\uff0c\u6709\u4e9b\u5382\u5546\u7684 JVM \u5728 Win7x64\uff0cJava8 \u73af\u5883\u914d\u7f6e\u5982\u4e0b UseG1GC\uff1a\n<\/p>\n<pre class=\"brush:java;\">\r\njava -Xmx12m -XX:+UseG1GC TestWrapper<\/pre>\n<p>\n\t\u7ed3\u679c\u4ea7\u751f\u7684\u9519\u8bef\u4fe1\u606f\u5374\u662f\uff1a\n<\/p>\n<pre class=\"brush:plain;\">\r\nException: java.lang.OutOfMemoryError thrown from the UncaughtExceptionHandler in thread &quot;main&quot;<\/pre>\n<p>\n\t\u4e0a\u9762\u8fd9\u4e9b\u771f\u5b9e\u7684\u6848\u4f8b\u8868\u660e\uff0c\u5728\u8d44\u6e90\u53d7\u9650\u7684\u60c5\u51b5\u4e0b\uff0c\u65e0\u6cd5\u51c6\u786e\u9884\u6d4b\u7a0b\u5e8f\u4f1a\u6b7b\u4e8e\u54ea\u79cd\u5177\u4f53\u7684\u539f\u56e0\u3002\u6240\u4ee5\u5728\u8fd9\u7c7b\u9519\u8bef\u9762\u524d\uff0c\u4e0d\u80fd\u7ed1\u6b7b\u67d0\u79cd\u7279\u5b9a\u7684\u9519\u8bef\u5904\u7406\u987a\u5e8f\u3002\n<\/p>\n<p>\n\t\u6709\u7684\u4eba\u5728\u89e3\u51b3 &ldquo;java.lang.OutOfMemoryError: GC overhead limit exceeded&rdquo; \u9519\u8bef\u65f6\uff0c\u914d\u7f6e\u4e86\u4e0b\u9762\u7684\u542f\u52a8\u53c2\u6570\uff1a\n<\/p>\n<pre class=\"brush:java;\">\r\n\/\/ \u4e0d\u63a8\u8350\r\n-XX:-UseGCOverheadLimit<\/pre>\n<p>\n\t\u6211\u544a\u8bc9\u4f60\uff0c\u8fd9\u662f\u4e00\u79cd\u5b8c\u5168\u9519\u8bef\u7684\u505a\u6cd5\u3002\u56e0\u4e3a UseGCOverheadLimit&nbsp;\u8fd9\u6837\u4f7f\u7528\u5e76\u4e0d\u80fd\u771f\u6b63\u5730\u89e3\u51b3\u95ee\u9898\uff0c\u53ea\u80fd\u63a8\u8fdf\u4e00\u70b9 out of memory \u9519\u8bef\u53d1\u751f\u7684\u65f6\u95f4\uff0c\u5230\u6700\u540e\u8fd8\u5f97\u8fdb\u884c\u5176\u4ed6\u5904\u7406\u3002\u6307\u5b9a\u8fd9\u4e2a\u9009\u9879\uff0c\u4f1a\u5c06\u539f\u6765\u7684 java.lang.OutOfMemoryError: GC overhead limit exceeded \u9519\u8bef\u63a9\u76d6\uff0c\u53d8\u6210\u66f4\u5e38\u89c1\u7684 java.lang.OutOfMemoryError: Java heap space \u9519\u8bef\u6d88\u606f\u3002\n<\/p>\n<p>\n\t\u6709\u65f6\u5019\u89e6\u53d1 GC overhead limit \u9519\u8bef\u7684\u539f\u56e0, \u662f\u56e0\u4e3a\u5206\u914d\u7ed9JVM\u7684\u5806\u5185\u5b58\u4e0d\u8db3\u3002\u8fd9\u79cd\u60c5\u51b5\u4e0b\u53ea\u9700\u8981\u589e\u52a0\u5806\u5185\u5b58\u5927\u5c0f\u5373\u53ef\u3002\n<\/p>\n<p>\n\t\u5728\u5927\u591a\u6570\u60c5\u51b5\u4e0b, \u589e\u52a0\u5806\u5185\u5b58\u5e76\u4e0d\u80fd\u89e3\u51b3\u95ee\u9898\u3002\u4f8b\u5982\u7a0b\u5e8f\u4e2d\u5b58\u5728\u5185\u5b58\u6cc4\u6f0f, \u589e\u52a0\u5806\u5185\u5b58\u53ea\u80fd\u63a8\u8fdf\u4ea7\u751f java.lang.OutOfMemoryError: Java heap space \u9519\u8bef\u7684\u65f6\u95f4\u3002\n<\/p>\n<p>\n\t\u6240\u4ee5\uff0c\u8981\u60f3\u4ece\u6839\u672c\u4e0a\u89e3\u51b3\u95ee\u9898\uff0c\u5219\u9700\u8981\u6392\u67e5\u5185\u5b58\u5206\u914d\u76f8\u5173\u7684\u4ee3\u7801\u3002\u7b80\u5355\u6765\u8bf4\uff0c\u9700\u8981\u641e\u6e05\u695a\u4e00\u4e0b\u4e24\u70b9\uff1a\n<\/p>\n<ul>\n<li>\n\t\t\u54ea\u7c7b\u5bf9\u8c61\u5360\u7528\u4e86\u6700\u591a\u5185\u5b58\uff1f\n\t<\/li>\n<li>\n\t\t\u8fd9\u4e9b\u5bf9\u8c61\u662f\u5728\u54ea\u90e8\u5206\u4ee3\u7801\u4e2d\u5206\u914d\u7684\uff1f\n\t<\/li>\n<\/ul>\n<p>\n\t\u89e3\u51b3\u8fd9\u7c7b\u95ee\u9898\u7684\u6d41\u7a0b\u548c\u6211\u4e0a\u7bc7\u6587\u7ae0\u300a<a href=\"https:\/\/www.xttblog.com\/?p=3345\" name=\"\u4e3a\u4ec0\u4e48\u4f1a\u4ea7\u751f java.lang.OutOfMemoryError: Java heap space \u9519\u8bef\u4ee5\u53ca\u5982\u4f55\u89e3\u51b3\uff1f\" target=\"_blank\" 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\u63d0\u5230\u7684\u6d41\u7a0b\u4e00\u81f4\u3002\u6211\u5c31\u4e0d\u518d\u5570\u55e6\u4e86\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.eu\/outofmemoryerror\/gc-overhead-limit-exceeded\" target=\"_blank\">https:\/\/plumbr.eu\/outofmemoryerror\/gc-overhead-limit-exceeded<\/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=3347\">\u8be6\u89e3 java.lang.OutOfMemoryError: GC overhead limit exceeded \u9519\u8bef\uff01<\/a><\/p><!-- <div class=\"bd-reward-stl\"><button id=\"bdRewardBtn\"><span><\/span><\/button><\/div> -->","protected":false},"excerpt":{"rendered":"<p>java \u4e2d\u6709\u51e0\u4e2a\u96be\u5144\u96be\u5f1f\uff0c\u6bd4\u5982\u6211\u6628\u5929\u5199\u7684 java.lang.OutOfMemoryError: Java  [&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":[1174,328,731,601,1744],"class_list":["post-3347","post","type-post","status-publish","format-standard","hentry","category-java","category-yyzt","tag-gc","tag-jvm","tag-outofmemoryerror","tag-useparallelgc"],"_links":{"self":[{"href":"https:\/\/www.xttblog.com\/index.php?rest_route=\/wp\/v2\/posts\/3347","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=3347"}],"version-history":[{"count":2,"href":"https:\/\/www.xttblog.com\/index.php?rest_route=\/wp\/v2\/posts\/3347\/revisions"}],"predecessor-version":[{"id":3349,"href":"https:\/\/www.xttblog.com\/index.php?rest_route=\/wp\/v2\/posts\/3347\/revisions\/3349"}],"wp:attachment":[{"href":"https:\/\/www.xttblog.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=3347"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.xttblog.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=3347"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.xttblog.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=3347"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}