{"id":16418,"date":"2024-10-08T13:38:47","date_gmt":"2024-10-08T05:38:47","guid":{"rendered":"https:\/\/92it.top\/?p=16418"},"modified":"2024-10-08T13:38:47","modified_gmt":"2024-10-08T05:38:47","slug":"%e7%ba%bf%e4%b8%8ajvm-oom%e9%97%ae%e9%a2%98%ef%bc%8c%e5%a6%82%e4%bd%95%e6%8e%92%e6%9f%a5%e5%92%8c%e8%a7%a3%e5%86%b3%ef%bc%9f","status":"publish","type":"post","link":"https:\/\/92it.top\/?p=16418","title":{"rendered":"\u7ebf\u4e0aJVM OOM\u95ee\u9898\uff0c\u5982\u4f55\u6392\u67e5\u548c\u89e3\u51b3\uff1f"},"content":{"rendered":"\n<p>\u8f6c\u8f7d\uff1a<a href=\"https:\/\/mp.weixin.qq.com\/s?__biz=MzIwNDAyOTI2Nw==&amp;mid=2247499695&amp;idx=1&amp;sn=715ab7f0a8137a348479095aaa797034&amp;chksm=96c4d393a1b35a85362e00ddb6a50a44f5c29a3aa1b05efdbeed508b2de28ec4c5f54145edb9&amp;cur_album_id=2818595943724974083&amp;scene=190#rd\">\u7ebf\u4e0aJVM OOM\u95ee\u9898\uff0c\u5982\u4f55\u6392\u67e5\u548c\u89e3\u51b3\uff1f<\/a><\/p>\n\n\n\n<p>JVM\uff08Java\u865a\u62df\u673a\uff09\u4e2d\u7684\u5185\u5b58\u4e0d\u8db3\u9519\u8bef\uff08Out of Memory Error, OOM\uff09\u662f\u8bb8\u591aJava\u5f00\u53d1\u8005\u5728\u751f\u4ea7\u73af\u5883\u4e2d\u9047\u5230\u7684\u5e38\u89c1\u95ee\u9898\u3002\u8fd9\u4e2a\u95ee\u9898\u53ef\u80fd\u51fa\u73b0\u5728\u4e0d\u540c\u7684\u5185\u5b58\u533a\u57df\uff0c\u5982\u5806\u5185\u5b58\u3001\u6c38\u4e45\u4ee3\/\u5143\u7a7a\u95f4\u3001\u6808\u5185\u5b58\u548c\u76f4\u63a5\u5185\u5b58\u7b49\u3002\u4e3a\u4e86\u7cfb\u7edf\u5730\u6392\u67e5\u548c\u89e3\u51b3\u8fd9\u4e9b\u95ee\u9898\uff0c\u8fd9\u7bc7\u6587\u7ae0\u6211\u4eec\u9700\u8981\u8be6\u7ec6\u5206\u6790\u6bcf\u4e2a\u73af\u8282\u548c\u89e3\u51b3\u7b56\u7565\u3002<\/p>\n\n\n\n<p><strong>\u7406\u89e3JVM\u5185\u5b58\u6a21\u578b<\/strong><\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<p>JVM\u5185\u5b58\u6a21\u578b\u4e3b\u8981\u5305\u62ec\u4ee5\u4e0b\u51e0\u4e2a\u5173\u952e\u533a\u57df\uff1a<\/p>\n\n\n\n<ol>\n<li><strong>\u5806\u5185\u5b58\uff08Heap Memory\uff09<\/strong>\uff1a\u7528\u4e8e\u5b58\u50a8\u5bf9\u8c61\u5b9e\u4f8b\u548c\u6570\u7ec4\u3002\u8fd9\u4e2a\u533a\u57df\u662f\u5783\u573e\u56de\u6536\u7684\u91cd\u70b9\u533a\u57df\u3002<\/li>\n\n\n\n<li><strong>\u65b9\u6cd5\u533a\uff08\u6c38\u4e45\u4ee3\/\u5143\u7a7a\u95f4\uff09\uff08Method Area, PermGen, Metaspace\uff09<\/strong>\uff1a\u7528\u4e8e\u5b58\u50a8\u7c7b\u7684\u5143\u6570\u636e\uff0c\u5982\u7c7b\u7684\u7ed3\u6784\u3001\u5b57\u6bb5\u3001\u65b9\u6cd5\u7b49\u3002JDK 8\u4e4b\u540e\u4f7f\u7528\u5143\u7a7a\u95f4\u66ff\u6362\u4e86\u6c38\u4e45\u4ee3\u3002<\/li>\n\n\n\n<li><strong>\u6808\u5185\u5b58\uff08Stack Memory\uff09<\/strong>\uff1a\u7528\u4e8e\u5b58\u50a8\u6bcf\u4e2a\u7ebf\u7a0b\u7684\u8fd0\u884c\u65f6\u65b9\u6cd5\u8c03\u7528\u6808\uff0c\u5305\u62ec\u65b9\u6cd5\u7684\u5c40\u90e8\u53d8\u91cf\u548c\u90e8\u5206\u8fd4\u56de\u4fe1\u606f\u3002<\/li>\n\n\n\n<li><strong>\u672c\u5730\u65b9\u6cd5\u6808\uff08Native Method Stack\uff09<\/strong>\uff1a\u4e0e\u6808\u5185\u5b58\u76f8\u4f3c\uff0c\u4f46\u7279\u522b\u7528\u4e8e\u672c\u5730\u65b9\u6cd5\u8c03\u7528\u3002<\/li>\n\n\n\n<li><strong>\u7a0b\u5e8f\u8ba1\u6570\u5668\uff08PC Register\uff09<\/strong>\uff1a\u6bcf\u4e2a\u7ebf\u7a0b\u90fd\u6709\u81ea\u5df1\u7684\u7a0b\u5e8f\u8ba1\u6570\u5668\uff0c\u7528\u4e8e\u8bb0\u5f55\u5f53\u524d\u7ebf\u7a0b\u5185\u7684\u5b57\u8282\u7801\u6307\u4ee4\u5730\u5740\u3002<\/li>\n\n\n\n<li><strong>\u76f4\u63a5\u5185\u5b58\uff08Direct Memory\uff09<\/strong>\uff1a\u4e0d\u7531JVM\u7ba1\u63a7\uff0c\u4e0eNIO\u76f8\u5173\uff0c\u7528\u4e8e\u9ad8\u6548\u7684I\/O\u64cd\u4f5c\u3002<\/li>\n<\/ol>\n\n\n\n<p><strong>\u5185\u5b58\u4e0d\u8db3\u7684\u5178\u578b\u75c7\u72b6\u53ca\u9519\u8bef\u4fe1\u606f<\/strong><\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<p><strong>\u5806\u5185\u5b58\u4e0d\u8db3<\/strong><\/p>\n\n\n\n<p>\u901a\u5e38\u629b\u51fa<code>java.lang.OutOfMemoryError: Java heap space<\/code>\u3002\u539f\u56e0\u53ef\u80fd\u662f\u5bf9\u8c61\u521b\u5efa\u8fc7\u591a\u6216\u5b58\u5728\u5185\u5b58\u6cc4\u6f0f\uff0c\u5bfc\u81f4\u5783\u573e\u56de\u6536\u65e0\u6cd5\u91ca\u653e\u5df2\u7528\u5185\u5b58\u3002<\/p>\n\n\n\n<p><strong>\u65b9\u6cd5\u533a\uff08\u6c38\u4e45\u4ee3\/\u5143\u7a7a\u95f4\uff09\u4e0d\u8db3<\/strong><\/p>\n\n\n\n<ul>\n<li><strong>\u6c38\u4e45\u4ee3\uff08PermGen\uff09\u4e0d\u8db3<\/strong>\uff1a\u629b\u51fa<code>java.lang.OutOfMemoryError: PermGen space<\/code>\u3002\u4e3b\u8981\u51fa\u73b0\u5728\u5e94\u7528\u7a0b\u5e8f\u52a0\u8f7d\u5927\u91cf\u7c7b\u65f6\uff0c\u5c24\u5176\u662f\u52a8\u6001\u7c7b\u751f\u6210\u3002<\/li>\n\n\n\n<li><strong>\u5143\u7a7a\u95f4\uff08Metaspace\uff09\u4e0d\u8db3<\/strong>\uff1a\u629b\u51fa<code>java.lang.OutOfMemoryError: Metaspace<\/code>\u3002JDK 8\u4e4b\u540e\u7684\u7248\u672c\u9002\u7528\u3002<\/li>\n<\/ul>\n\n\n\n<p><strong>\u6808\u5185\u5b58\u4e0d\u8db3<\/strong><\/p>\n\n\n\n<p>\u629b\u51fa<code>java.lang.StackOverflowError<\/code>\uff0c\u901a\u5e38\u4e0e\u9012\u5f52\u8c03\u7528\u8fc7\u6df1\u6216\u65b9\u6cd5\u8c03\u7528\u8fc7\u591a\u6709\u5173\u3002<\/p>\n\n\n\n<p><strong>\u76f4\u63a5\u5185\u5b58\u4e0d\u8db3<\/strong><\/p>\n\n\n\n<p>\u629b\u51fa<code>java.lang.OutOfMemoryError: Direct buffer memory<\/code>\uff0c\u901a\u5e38\u4e0eNIO\u6216\u5927\u6570\u636e\u5904\u7406\u6709\u5173\u3002<\/p>\n\n\n\n<p><strong>\u5783\u573e\u6536\u96c6\u8fc7\u5ea6<\/strong><\/p>\n\n\n\n<p>\u629b\u51fa<code>java.lang.OutOfMemoryError: GC overhead limit exceeded<\/code>\uff0c\u610f\u5473\u7740\u5783\u573e\u56de\u6536\u5668\u5728\u5c1d\u8bd5\u56de\u6536\u5185\u5b58\u65f6\uff0c\u6d88\u8017\u4e86\u8fc7\u591a\u65f6\u95f4\u3002<\/p>\n\n\n\n<p><strong>\u6392\u67e5OOM\u95ee\u9898\u7684\u6b65\u9aa4<\/strong><\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<p><strong>\u542f\u7528\u8bca\u65ad\u9009\u9879<\/strong><\/p>\n\n\n\n<p>\u4e3a\u4e86\u89e3\u51b3OOM\u95ee\u9898\uff0c\u53ef\u4ee5\u9996\u5148\u542f\u7528\u4e00\u4e9bJVM\u8bca\u65ad\u9009\u9879\uff1a<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">-XX:+HeapDumpOnOutOfMemoryError\n-XX:HeapDumpPath=&lt;file-path>\n-Xlog:gc* (\u9488\u5bf9JVM 9\u53ca\u4ee5\u4e0a)\n-XX:+PrintGCDetails -Xloggc:&lt;file-path> (\u9488\u5bf9JVM 8\u53ca\u4ee5\u4e0b)<\/pre>\n\n\n\n<p>\u8fd9\u4e9b\u9009\u9879\u53ef\u4ee5\u751f\u6210\u5185\u5b58\u5806\u8f6c\u50a8\u548cGC\u65e5\u5fd7\u6587\u4ef6\uff0c\u5e2e\u52a9\u5206\u6790\u95ee\u9898\u7684\u6839\u6e90\u3002<\/p>\n\n\n\n<p><strong>\u5206\u6790\u9519\u8bef\u65e5\u5fd7<\/strong><\/p>\n\n\n\n<p>\u68c0\u67e5\u5e94\u7528\u7a0b\u5e8f\u65e5\u5fd7\u53caOOM\u9519\u8bef\u5806\u6808\u4fe1\u606f\uff0c\u627e\u51fa\u5177\u4f53\u7684\u5185\u5b58\u533a\u57df\u95ee\u9898\u3002<\/p>\n\n\n\n<p><strong>\u5206\u6790\u5806\u8f6c\u50a8\u6587\u4ef6<\/strong><\/p>\n\n\n\n<p>\u4f7f\u7528\u50cfJVisualVM\u3001Eclipse MAT\u3001JProfiler\u7b49\u5206\u6790\u5de5\u5177\u67e5\u770b\u751f\u6210\u7684\u5806\u8f6c\u50a8\u6587\u4ef6\uff0c\u627e\u51fa\u5185\u5b58\u4f7f\u7528\u7684\u70ed\u70b9\u5bf9\u8c61\u3001\u5185\u5b58\u6cc4\u6f0f\u53ca\u5176\u539f\u56e0\u3002<\/p>\n\n\n\n<p><strong>\u68c0\u67e5GC\u65e5\u5fd7<\/strong><\/p>\n\n\n\n<p>\u5206\u6790\u5783\u573e\u56de\u6536\u65e5\u5fd7\uff0c\u8bc4\u4f30\u5783\u573e\u56de\u6536\u9891\u7387\u3001\u6682\u505c\u65f6\u95f4\u548c\u5404\u5185\u5b58\u533a\u7684\u4f7f\u7528\u60c5\u51b5\u3002<\/p>\n\n\n\n<p><strong>\u4ee3\u7801\u5ba1\u67e5\u548c\u4f18\u5316<\/strong><\/p>\n\n\n\n<p>\u901a\u8fc7\u4ee3\u7801\u5ba1\u67e5\uff0c\u68c0\u67e5\u662f\u5426\u5b58\u5728\u5982\u7f13\u5b58\u672a\u6e05\u7406\u3001\u9759\u6001\u96c6\u5408\u589e\u957f\u8fc7\u5feb\u7b49\u5185\u5b58\u6cc4\u6f0f\u95ee\u9898\u3002\u4f18\u5316\u4ee3\u7801\uff0c\u51cf\u5c11\u5bf9\u8c61\u521b\u5efa\u548c\u4f7f\u7528\u5185\u5b58\u3002<\/p>\n\n\n\n<p><strong>\u89e3\u51b3\u65b9\u6848<\/strong><\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<p><strong>\u589e\u52a0\u5185\u5b58<\/strong><\/p>\n\n\n\n<p><strong>\u5806\u5185\u5b58<\/strong>\uff1a\u901a\u8fc7\u8c03\u6574<code>-Xmx<\/code>\u589e\u52a0\u6700\u5927\u5806\u5185\u5b58\uff1a<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">java -Xmx2g -jar MyApp.jar<\/pre>\n\n\n\n<p><strong>\u6c38\u4e45\u4ee3\/\u5143\u7a7a\u95f4<\/strong>\uff1a\u901a\u8fc7<code>-XX:MaxPermSize<\/code>\uff08JDK 7\u53ca\u4ee5\u4e0b\uff09\u6216<code>-XX:MaxMetaspaceSize<\/code>\uff08JDK 8\u53ca\u4ee5\u4e0a\uff09\u589e\u52a0\uff1a<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">java -XX:MaxPermSize=512m -jar MyApp.jar\njava -XX:MaxMetaspaceSize=512m -jar MyApp.jar<\/pre>\n\n\n\n<p><strong>\u76f4\u63a5\u5185\u5b58<\/strong>\uff1a\u901a\u8fc7<code>-XX:MaxDirectMemorySize<\/code>\u589e\u52a0\uff1a<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">java -XX:MaxDirectMemorySize=512m -jar MyApp.jar<\/pre>\n\n\n\n<p><strong>\u4f18\u5316\u4ee3\u7801<\/strong><\/p>\n\n\n\n<ul>\n<li><strong>\u91ca\u653e\u4e0d\u5fc5\u8981\u7684\u5bf9\u8c61<\/strong>\uff1a\u786e\u4fdd\u672a\u4f7f\u7528\u5bf9\u8c61\u80fd\u88ab\u5783\u573e\u56de\u6536\u3002<\/li>\n\n\n\n<li><strong>\u907f\u514d\u5927\u5bf9\u8c61\u521b\u5efa<\/strong>\uff1a\u5728\u53ef\u80fd\u7684\u60c5\u51b5\u4e0b\uff0c\u51cf\u5c11\u5927\u5bf9\u8c61\u7684\u4f7f\u7528\u3002<\/li>\n\n\n\n<li><strong>\u4f7f\u7528\u5f31\u5f15\u7528\/\u8f6f\u5f15\u7528<\/strong>\uff1a\u5982\u7f13\u5b58\u53ef\u4ee5\u4f7f\u7528<code>WeakHashMap<\/code>\u6216<code>SoftReference<\/code>\u6765\u907f\u514d\u5185\u5b58\u6cc4\u6f0f\u3002<\/li>\n<\/ul>\n\n\n\n<p><strong>\u8c03\u4f18\u5783\u573e\u56de\u6536\u5668\u9009\u9879<\/strong><\/p>\n\n\n\n<p>\u9009\u62e9\u9002\u5408\u5e94\u7528\u7684GC\u7b97\u6cd5\uff08\u5982G1\u3001CMS\uff09\u548c\u4f18\u5316\u5176\u53c2\u6570\uff1a<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">java -XX:+UseG1GC -XX:MaxGCPauseMillis=200 -jar MyApp.jar<\/pre>\n\n\n\n<p><strong>\u7ba1\u7406\u5916\u90e8\u8d44\u6e90<\/strong><\/p>\n\n\n\n<p>\u786e\u4fdd\u6587\u4ef6\u53e5\u67c4\u3001\u6570\u636e\u5e93\u8fde\u63a5\u7b49\u5916\u90e8\u8d44\u6e90\u80fd\u6b63\u786e\u5173\u95ed\u548c\u91ca\u653e\u3002<\/p>\n\n\n\n<p><strong>\u6301\u7eed\u76d1\u63a7\u548c\u9884\u8b66<\/strong><\/p>\n\n\n\n<p>\u4f7f\u7528JMX\u3001Prometheus\u3001Grafana\u7b49\u5de5\u5177\u6301\u7eed\u76d1\u63a7JVM\u5185\u5b58\u4f7f\u7528\u60c5\u51b5\uff0c\u5e76\u5efa\u7acb\u9884\u8b66\u673a\u5236\u3002\u793a\u4f8b\u5982\u4e0b\uff1a<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">ManagementFactory.getMemoryMXBean().getHeapMemoryUsage();<\/pre>\n\n\n\n<p><strong>\u5b9e\u8df5\u6848\u4f8b\u5206\u6790<\/strong><\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<p>\u4ee5\u4e0b\u662f\u51e0\u4e2a\u5e38\u89c1\u7684OOM\u95ee\u9898\u6848\u4f8b\u53ca\u5176\u89e3\u51b3\u8fc7\u7a0b\uff1a<\/p>\n\n\n\n<p><strong>\u6848\u4f8b\u4e00\uff1a\u5927\u6570\u636e\u91cf\u5904\u7406\u5bfc\u81f4\u7684\u5806\u5185\u5b58\u4e0d\u8db3<\/strong><\/p>\n\n\n\n<p><strong>1. \u75c7\u72b6<\/strong>\uff1a\u5e94\u7528\u5904\u7406\u5927\u6570\u636e\u91cf\u65f6\u629b\u51fa<code>java.lang.OutOfMemoryError: Java heap space<\/code>\u3002<strong>2. \u6392\u67e5<\/strong>\uff1a<\/p>\n\n\n\n<ul>\n<li>\u542f\u7528GC\u65e5\u5fd7\u548c\u5806\u8f6c\u50a8\u9009\u9879\u3002<\/li>\n\n\n\n<li>\u5206\u6790GC\u65e5\u5fd7\uff0c\u53d1\u73b0\u5e94\u7528\u9891\u7e41\u8fdb\u884cFull GC\uff0c\u4e14\u6548\u679c\u4e0d\u660e\u663e\u3002<\/li>\n\n\n\n<li>\u4f7f\u7528JVisualVM\u5206\u6790\u5806\u8f6c\u50a8\u6587\u4ef6\uff0c\u53d1\u73b0\u5927\u91cf\u5927\u5bf9\u8c61\u5360\u7528\u5185\u5b58\u3002<strong>3.\u89e3\u51b3<\/strong>\uff1a<\/li>\n\n\n\n<li>\u4f18\u5316\u7b97\u6cd5\uff0c\u51cf\u5c11\u5185\u5b58\u5360\u7528\u3002<\/li>\n\n\n\n<li>\u901a\u8fc7<code>-Xmx<\/code>\u589e\u52a0\u5806\u5185\u5b58\u3002<\/li>\n\n\n\n<li>\u6539\u8fdb\u6570\u636e\u5904\u7406\u6d41\u7a0b\uff0c\u4f7f\u7528\u6d41\u5f0f\u5904\u7406\u7b49\u6280\u672f\u51cf\u5c11\u5cf0\u503c\u5185\u5b58\u5360\u7528\u3002<\/li>\n<\/ul>\n\n\n\n<p><strong>\u6848\u4f8b\u4e8c\uff1a\u52a8\u6001\u7c7b\u751f\u6210\u5bfc\u81f4\u7684\u5143\u7a7a\u95f4\u4e0d\u8db3<\/strong><strong>1.\u75c7\u72b6<\/strong>\uff1a\u52a8\u6001\u751f\u6210\u7c7b\u65f6\u629b\u51fa<code>java.lang.OutOfMemoryError: Metaspace<\/code>\u3002<strong>2.\u6392\u67e5<\/strong>\uff1a<\/p>\n\n\n\n<ul>\n<li>\u542f\u7528\u5806\u8f6c\u50a8\u548cGC\u65e5\u5fd7\u9009\u9879\u3002<\/li>\n\n\n\n<li>\u5206\u6790GC\u65e5\u5fd7\uff0c\u53d1\u73b0\u5143\u7a7a\u95f4\u589e\u957f\u8fc5\u901f\uff0c\u4e14\u7c7b\u52a0\u8f7d\u9891\u7e41\u3002<\/li>\n\n\n\n<li>\u901a\u8fc7\u5de5\u5177\u67e5\u770b\u5143\u7a7a\u95f4\u5185\u5bb9\uff0c\u53d1\u73b0\u5927\u91cf\u52a8\u6001\u751f\u6210\u7684\u7c7b\u672a\u88ab\u5378\u8f7d\u3002<strong>3.\u89e3\u51b3<\/strong>\uff1a<\/li>\n\n\n\n<li>\u901a\u8fc7<code>-XX:MaxMetaspaceSize<\/code>\u589e\u52a0\u5143\u7a7a\u95f4\u5927\u5c0f\u3002<\/li>\n\n\n\n<li>\u4f18\u5316\u52a8\u6001\u7c7b\u751f\u6210\u903b\u8f91\uff0c\u51cf\u5c11\u4e0d\u5fc5\u8981\u7684\u7c7b\u52a0\u8f7d\u3002<\/li>\n<\/ul>\n\n\n\n<p><strong>\u6848\u4f8b\u4e09\uff1a\u9012\u5f52\u8c03\u7528\u8fc7\u6df1\u5bfc\u81f4\u7684\u6808\u5185\u5b58\u4e0d\u8db3<\/strong><strong>1.\u75c7\u72b6<\/strong>\uff1a\u9012\u5f52\u8c03\u7528\u629b\u51fa<code>java.lang.StackOverflowError<\/code>\u3002<strong>2.\u6392\u67e5<\/strong>\uff1a\u5206\u6790\u9519\u8bef\u5806\u6808\uff0c\u53d1\u73b0\u9012\u5f52\u8c03\u7528\u6df1\u5ea6\u8fc7\u5927\u3002<\/p>\n\n\n\n<p><strong>3.\u89e3\u51b3<\/strong>\uff1a<\/p>\n\n\n\n<ul>\n<li>\u6539\u7528\u8fed\u4ee3\u7b97\u6cd5\u66ff\u4ee3\u9012\u5f52\u3002<\/li>\n\n\n\n<li>\u9002\u5f53\u4f18\u5316\u7b97\u6cd5\uff0c\u51cf\u5c11\u9012\u5f52\u6df1\u5ea6\u3002<\/li>\n<\/ul>\n\n\n\n<p>\u901a\u8fc7\u4ee5\u4e0a\u6b65\u9aa4\u548c\u5b9e\u8df5\u6848\u4f8b\uff0c\u5f00\u53d1\u8005\u53ef\u4ee5\u7cfb\u7edf\u6027\u5730\u6392\u67e5\u548c\u89e3\u51b3JVM\u5185\u5b58\u4e0d\u8db3\u95ee\u9898\uff0c\u786e\u4fddJava\u5e94\u7528\u7684\u7a33\u5b9a\u6027\u548c\u6027\u80fd\u3002<\/p>\n\n\n\n<p><strong>\u603b\u7ed3<\/strong><\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<p>\u672c\u6587\u6211\u4eec\u5bf9JVM OOM\u8fdb\u884c\u4e86\u5168\u9762 \u5bf9\u5206\u6790\uff0c\u8fd9\u4e9b\u95ee\u9898\u901a\u5e38\u6d89\u53ca\u5185\u5b58\u4e0d\u8db3\u5bfc\u81f4\u7684<code>java.lang.OutOfMemoryError<\/code>\u5f02\u5e38\uff0c\u53ef\u80fd\u51fa\u73b0\u5728\u5806\u5185\u5b58\u3001\u6c38\u4e45\u4ee3\/\u5143\u7a7a\u95f4\u3001\u6808\u5185\u5b58\u6216\u76f4\u63a5\u5185\u5b58\u7b49\u533a\u57df\u3002\u6392\u67e5\u6b65\u9aa4\u5305\u62ec\u542f\u7528\u8bca\u65ad\u9009\u9879\uff08\u5982\u5806\u8f6c\u50a8\u548cGC\u65e5\u5fd7\uff09\u3001\u5206\u6790\u9519\u8bef\u65e5\u5fd7\u548c\u5806\u8f6c\u50a8\u6587\u4ef6\u3001\u4ee5\u53ca\u68c0\u67e5\u5783\u573e\u56de\u6536\u65e5\u5fd7\u3002\u89e3\u51b3\u65b9\u6cd5\u6709\u589e\u52a0\u5185\u5b58\uff08\u5982\u8c03\u6574<code>-Xmx<\/code>\u3001<code>-XX:MaxMetaspaceSize<\/code>\u7b49\uff09\u3001\u4f18\u5316\u4ee3\u7801\uff08\u51cf\u5c11\u5927\u5bf9\u8c61\u3001\u53ca\u65f6\u91ca\u653e\u4e0d\u5fc5\u8981\u7684\u5bf9\u8c61\uff09\u3001\u8c03\u4f18\u5783\u573e\u56de\u6536\u5668\u53c2\u6570\uff08\u9009\u62e9\u5408\u9002\u7684GC\u7b97\u6cd5\u548c\u8c03\u6574\u5806\u5927\u5c0f\uff09\u548c\u7ba1\u7406\u5916\u90e8\u8d44\u6e90\uff08\u6b63\u786e\u5173\u95ed\u6587\u4ef6\u53e5\u67c4\u548c\u6570\u636e\u5e93\u8fde\u63a5\uff09\u3002\u6301\u7eed\u76d1\u63a7\uff08\u4f7f\u7528JMX\u3001Prometheus\u7b49\uff09\u548c\u9884\u8b66\u673a\u5236\u53ef\u9884\u9632OOM\u95ee\u9898\u3002\u901a\u8fc7\u8fd9\u4e9b\u6b65\u9aa4\uff0c\u53ef\u4ee5\u6709\u6548\u6392\u67e5\u548c\u89e3\u51b3JVM OOM\u95ee\u9898\uff0c\u786e\u4fdd\u5e94\u7528\u7a33\u5b9a\u8fd0\u884c\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u8f6c\u8f7d\uff1a\u7ebf\u4e0aJVM OOM\u95ee\u9898\uff0c\u5982\u4f55\u6392\u67e5\u548c\u89e3\u51b3\uff1f JVM\uff08Java\u865a\u62df\u673a\uff09\u4e2d\u7684\u5185\u5b58\u4e0d\u8db3\u9519\u8bef\uff08Out of Mem [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[26],"tags":[],"_links":{"self":[{"href":"https:\/\/92it.top\/index.php?rest_route=\/wp\/v2\/posts\/16418"}],"collection":[{"href":"https:\/\/92it.top\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/92it.top\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/92it.top\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/92it.top\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=16418"}],"version-history":[{"count":1,"href":"https:\/\/92it.top\/index.php?rest_route=\/wp\/v2\/posts\/16418\/revisions"}],"predecessor-version":[{"id":16419,"href":"https:\/\/92it.top\/index.php?rest_route=\/wp\/v2\/posts\/16418\/revisions\/16419"}],"wp:attachment":[{"href":"https:\/\/92it.top\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=16418"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/92it.top\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=16418"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/92it.top\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=16418"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}