{"id":14120,"date":"2023-07-26T08:58:27","date_gmt":"2023-07-26T00:58:27","guid":{"rendered":"https:\/\/blog.ywdevops.cn\/?p=14120"},"modified":"2023-07-26T11:34:50","modified_gmt":"2023-07-26T03:34:50","slug":"jvm-3","status":"publish","type":"post","link":"https:\/\/blog.ywdevops.cn\/index.php\/2023\/07\/26\/jvm-3\/","title":{"rendered":"JVM\u8c03\u4f18"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">JVM\u8c03\u4f18\u4e3b\u8981\u662f\u51cf\u5c11GC\u7684\u9891\u7387\u548cFull GC\u6b21\u6570\uff0cSTW\uff08stop the world\uff09\u7684\u505c\u987f\u65f6\u95f4\u548c\u6b21\u6570<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">STW(Stop The World)\u5728Java\u5783\u573e\u6536\u96c6\u5668\u4e2d\u7684\u4e00\u4e2a\u6982\u5ff5,\u610f\u601d\u662f\u201c\u505c\u6b62\u4e16\u754c\u201d\u3002\u5b83\u6307\u7684\u662f\u5728\u5783\u573e\u6536\u96c6\u65f6,Java\u865a\u62df\u673a\u6682\u505c\u5176\u4ed6\u6240\u6709\u7684\u5de5\u4f5c\u7ebf\u7a0b,\u53ea\u6709\u5783\u573e\u6536\u96c6\u7ebf\u7a0b\u5728\u5de5\u4f5c<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u5728STW\u671f\u95f4,\u9664\u4e86GC\u7ebf\u7a0b\u5916,\u6240\u6709\u7684Java\u5e94\u7528\u7a0b\u5e8f\u7ebf\u7a0b\u90fd\u4f1a\u88ab\u6302\u8d77,\u4f7f\u7a0b\u5e8f\u6682\u505c\u6267\u884c\u3002STW\u7684\u76ee\u7684\u662f\u4e3a\u4e86\u5728\u8fdb\u884cGC\u65f6\u9632\u6b62\u5e94\u7528\u7a0b\u5e8f\u7ebf\u7a0b\u548cGC\u7ebf\u7a0b\u540c\u65f6\u8bbf\u95eeJava\u5806,\u4fdd\u8bc1\u5783\u573e\u6536\u96c6\u7684\u539f\u5b50\u6027<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">jvm\u4f18\u5316\u539f\u5219\u5c3d\u53ef\u80fd\u8ba9\u5bf9\u8c61\u90fd\u5728\u65b0\u751f\u4ee3\u91cc\u5206\u914d\u548c\u56de\u6536\uff0c\u5c3d\u91cf\u522b\u8ba9\u592a\u591a\u5bf9\u8c61\u9891\u7e41\u8fdb\u5165\u8001\u5e74\u4ee3\uff0c\u907f\u514d\u9891\u7e41\u5bf9\u8001\u5e74\u4ee3\u8fdb\u884c\u5783\u573e\u56de\u6536\uff0c\u540c\u65f6\u7ed9\u7cfb\u7edf\u5145\u8db3\u7684\u5185\u5b58\u5927\u5c0f\uff0c\u907f\u514d\u65b0\u751f\u4ee3\u9891\u7e41\u7684\u8fdb\u884c\u5783\u573e\u56de\u6536<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u4ec0\u4e48\u6837\u7684\u60c5\u51b5\u4e0b\u4f1a\u6709Full GC\u53d1\u751f<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u8001\u5e74\u4ee3\u7a7a\u95f4\u4e0d\u8db3\uff1aSurvivor\u533a\u57df\u7684\u5bf9\u8c61\u6ee1\u8db3\u664b\u5347\u5230\u8001\u5e74\u4ee3\u7684\u6761\u4ef6\u65f6\uff0c\u664b\u5347\u8fdb\u5165\u8001\u5e74\u4ee3\u7684\u5bf9\u8c61\u5927\u5c0f\u5927\u4e8e\u8001\u5e74\u4ee3\u7684\u53ef\u7528\u5185\u5b58\uff0c\u8fd9\u4e2a\u65f6\u5019\u4f1a\u89e6\u53d1Full GC\u3002\uff0c\u5f53\u6267\u884cFull GC\u540e\u7a7a\u95f4\u4ecd\u7136\u4e0d\u8db3\uff0c\u5219\u629b\u51fa\u9519\u8bef\uff1ajava.lang.OutOfMemoryError: Java heap space \u3002\u4e3a\u907f\u514d\u4ee5\u4e0a\u4e24\u79cd\u72b6\u51b5\u5f15\u8d77\u7684FullGC\uff0c\u8c03\u4f18\u65f6\u5e94\u5c3d\u91cf\u505a\u5230\u8ba9\u5bf9\u8c61\u5728Minor GC\u9636\u6bb5\u88ab\u56de\u6536\u3001\u8ba9\u5bf9\u8c61\u5728\u65b0\u751f\u4ee3\u591a\u5b58\u6d3b\u4e00\u6bb5\u65f6\u95f4\u53ca\u4e0d\u8981\u521b\u5efa\u8fc7\u5927\u7684\u5bf9\u8c61\u53ca\u6570\u7ec4<\/li>\n\n\n\n<li>Metaspace\u533a\u5185\u5b58\u8fbe\u5230\u9608\u503c\uff1aMetaspace\u4f7f\u7528\u7684\u662f\u672c\u5730\u5185\u5b58\uff0c\u800c\u4e0d\u662f\u5806\u5185\u5b58\uff0c\u5982\u679c\u8bbe\u7f6e-XX:MetaspaceSize\u53c2\u6570\uff0c\u90a3\u4e48\u8d85\u8fc7\u8fd9\u4e2a\u503c\u5c31\u4f1a\u89e6\u53d1FULL GC<\/li>\n\n\n\n<li>\u5806\u4e2d\u4ea7\u751f\u5927\u5bf9\u8c61\u8d85\u8fc7\u9608\u503c\uff1a\u8fd9\u4e2a\u53c2\u6570\u53ef\u4ee5\u901a\u8fc7-XX:PretenureSizeThreshold\u8fdb\u884c\u8bbe\u5b9a\uff0c\u5927\u5bf9\u8c61\u6216\u8005\u957f\u671f\u5b58\u6d3b\u7684\u5bf9\u8c61\u8fdb\u5165\u8001\u5e74\u4ee3\uff0c\u5178\u578b\u7684\u5927\u5bf9\u8c61\u5c31\u662f\u5f88\u957f\u7684\u5b57\u7b26\u4e32\u6216\u8005\u6570\u7ec4\uff0c\u5b83\u4eec\u5728\u88ab\u521b\u5efa\u540e\u4f1a\u76f4\u63a5\u8fdb\u5165\u8001\u5e74\u4ee3\uff0c\u5728\u8981\u653e\u7f6e\u7684\u65f6\u5019JVM\u5982\u679c\u53d1\u73b0\u8001\u5e74\u4ee3\u7684\u7a7a\u95f4\u4e0d\u8db3\u65f6\uff0c\u4f1a\u89e6\u53d1Full GC<\/li>\n\n\n\n<li>\u8001\u5e74\u4ee3\u8fde\u7eed\u7a7a\u95f4\u4e0d\u8db3\uff1aJVM\u5982\u679c\u5224\u65ad\u8001\u5e74\u4ee3\u6ca1\u6709\u505a\u8db3\u591f\u7684\u8fde\u7eed\u7a7a\u95f4\u6765\u653e\u7f6e\u5927\u5bf9\u8c61\uff0c\u90a3\u4e48\u5c31\u4f1a\u5f15\u8d77Full GC\uff0c\u4f8b\u5982\u8001\u5e74\u4ee3\u53ef\u7528\u7a7a\u95f4\u5927\u5c0f\u4e3a100K\uff0c\u4f46\u4e0d\u662f\u8fde\u7eed\u7684\uff0c\u8fde\u7eed\u5185\u5b58\u53ea\u898180K\uff0c\u800c\u664b\u5347\u5230\u8001\u5e74\u4ee3\u7684\u5bf9\u8c61\u5927\u5c0f\u4e3a100K\uff0c\u7531\u4e8e100\uff1e80\u7684\u8fde\u7eed\u7a7a\u95f4\uff0c\u6240\u4ee5\u5c31\u4f1a\u89e6\u53d1Full GC<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">\u4ec0\u4e48\u60c5\u51b5\u4e0b\u9700\u8981\u8fdb\u884cJVM\u8c03\u4f18\uff1f<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Heap\u5185\u5b58\uff08\u8001\u5e74\u4ee3\uff09\u6301\u7eed\u4e0a\u6da8\u8fbe\u5230\u8bbe\u7f6e\u7684\u6700\u5927\u5185\u5b58\u503c<\/li>\n\n\n\n<li>Full GC \u6b21\u6570\u9891\u7e41<\/li>\n\n\n\n<li>GC \u505c\u987f\u65f6\u95f4\u8fc7\u957f\uff08\u8d85\u8fc71\u79d2\uff09<\/li>\n\n\n\n<li>\u5e94\u7528\u51fa\u73b0OutOfMemory \u7b49\u5185\u5b58\u5f02\u5e38<\/li>\n\n\n\n<li>\u5e94\u7528\u4e2d\u6709\u4f7f\u7528\u672c\u5730\u7f13\u5b58\u4e14\u5360\u7528\u5927\u91cf\u5185\u5b58\u7a7a\u95f4<\/li>\n\n\n\n<li>\u7cfb\u7edf\u541e\u5410\u91cf\u4e0e\u54cd\u5e94\u6027\u80fd\u4e0d\u9ad8\u6216\u4e0b\u964d<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">\u4e00\u3001\u4f7f\u7528jstack\u627e\u51fa\u5360\u7528CPU\u6700\u9ad8\u7684\u7ebf\u7a0b\u5806\u6808\u4fe1\u606f<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">1\u3001\u901a\u8fc7\u547d\u4ee4top -p pid\uff0c\u67e5\u770bjava\u8fdb\u7a0b\u7684\u5185\u5b58\u60c5\u51b5\uff0c\u5982\u56fe\uff1a<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"703\" height=\"211\" src=\"https:\/\/blog.ywdevops.cn\/wp-content\/uploads\/2023\/07\/7-6.png\" alt=\"\" class=\"wp-image-14134\" srcset=\"https:\/\/blog.ywdevops.cn\/wp-content\/uploads\/2023\/07\/7-6.png 703w, https:\/\/blog.ywdevops.cn\/wp-content\/uploads\/2023\/07\/7-6-300x90.png 300w, https:\/\/blog.ywdevops.cn\/wp-content\/uploads\/2023\/07\/7-6-600x180.png 600w\" sizes=\"auto, (max-width: 703px) 100vw, 703px\" \/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">2\u3001\u6309H\uff0c\u83b7\u53d6\u6bcf\u4e2a\u7ebf\u7a0b\u7684\u5185\u5b58\u60c5\u51b5\uff0c\u5982\u56fe\uff1a<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"705\" height=\"224\" src=\"https:\/\/blog.ywdevops.cn\/wp-content\/uploads\/2023\/07\/8-6.png\" alt=\"\" class=\"wp-image-14136\" srcset=\"https:\/\/blog.ywdevops.cn\/wp-content\/uploads\/2023\/07\/8-6.png 705w, https:\/\/blog.ywdevops.cn\/wp-content\/uploads\/2023\/07\/8-6-300x95.png 300w, https:\/\/blog.ywdevops.cn\/wp-content\/uploads\/2023\/07\/8-6-600x191.png 600w\" sizes=\"auto, (max-width: 705px) 100vw, 705px\" \/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">3\u3001\u5c06\u4e0a\u9762\u5360\u7528cpu\u548c\u5185\u5b58\u8f83\u9ad8\u7684\u7ebf\u7a0bpid\u8f6c\u4e3a16\u8fdb\u5236\uff0c\u7136\u540e\u83b7\u53d6\u5806\u6808\u4fe1\u606f\uff0c\u5982\u4e0b\uff1a<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"705\" height=\"264\" src=\"https:\/\/blog.ywdevops.cn\/wp-content\/uploads\/2023\/07\/9-6.png\" alt=\"\" class=\"wp-image-14138\" srcset=\"https:\/\/blog.ywdevops.cn\/wp-content\/uploads\/2023\/07\/9-6.png 705w, https:\/\/blog.ywdevops.cn\/wp-content\/uploads\/2023\/07\/9-6-300x112.png 300w, https:\/\/blog.ywdevops.cn\/wp-content\/uploads\/2023\/07\/9-6-600x225.png 600w\" sizes=\"auto, (max-width: 705px) 100vw, 705px\" \/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">\u4e0a\u9762\u662f\u6253\u5370\u8fd9\u4e2a\u7ebf\u7a0b\u7684\u540e10\u884c\u4fe1\u606f\uff0c\u53ef\u4ee5\u770b\u5230\u5bfc\u81f4CPU\u98d9\u9ad8\u7684\u8c03\u7528\u65b9\u5f0f\u662f\u4ec0\u4e48<\/p>\n","protected":false},"excerpt":{"rendered":"<p>JVM\u8c03\u4f18\u4e3b\u8981\u662f\u51cf\u5c11GC\u7684\u9891\u7387\u548cFull GC\u6b21\u6570\uff0cSTW\uff08stop the world\uff09\u7684\u505c\u987f\u65f6\u95f4\u548c\u6b21\u6570 S [&hellip;]<\/p>\n","protected":false},"author":3,"featured_media":14121,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[119],"tags":[],"class_list":["post-14120","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-java"],"blocksy_meta":{"styles_descriptor":{"styles":{"desktop":"","tablet":"","mobile":""},"google_fonts":[],"version":8}},"_links":{"self":[{"href":"https:\/\/blog.ywdevops.cn\/index.php\/wp-json\/wp\/v2\/posts\/14120","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.ywdevops.cn\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.ywdevops.cn\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.ywdevops.cn\/index.php\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.ywdevops.cn\/index.php\/wp-json\/wp\/v2\/comments?post=14120"}],"version-history":[{"count":13,"href":"https:\/\/blog.ywdevops.cn\/index.php\/wp-json\/wp\/v2\/posts\/14120\/revisions"}],"predecessor-version":[{"id":14154,"href":"https:\/\/blog.ywdevops.cn\/index.php\/wp-json\/wp\/v2\/posts\/14120\/revisions\/14154"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/blog.ywdevops.cn\/index.php\/wp-json\/wp\/v2\/media\/14121"}],"wp:attachment":[{"href":"https:\/\/blog.ywdevops.cn\/index.php\/wp-json\/wp\/v2\/media?parent=14120"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.ywdevops.cn\/index.php\/wp-json\/wp\/v2\/categories?post=14120"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.ywdevops.cn\/index.php\/wp-json\/wp\/v2\/tags?post=14120"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}