{"id":176,"date":"2024-12-15T19:47:20","date_gmt":"2024-12-15T19:47:20","guid":{"rendered":"https:\/\/www.isvmspace.com\/?p=176"},"modified":"2024-12-15T19:47:20","modified_gmt":"2024-12-15T19:47:20","slug":"jvm%e7%b3%bb%e5%88%97-%e5%9e%83%e5%9c%be%e6%94%b6%e9%9b%86%e5%99%a8","status":"publish","type":"post","link":"https:\/\/www.isvmspace.com\/?p=176","title":{"rendered":"JVM\u7cfb\u5217-\u5783\u573e\u6536\u96c6\u5668"},"content":{"rendered":"<h1>\u5206\u7c7b<\/h1>\n<p><img decoding=\"async\" src=\"https:\/\/www.isvmspace.com\/wp-content\/uploads\/2023\/02\/\u5783\u573e\u6536\u96c6\u5668\u5206\u7c7b.png\" alt=\"\" \/><\/p>\n<h2>\u4e32\u884c<\/h2>\n<p>\u4e0d\u4ec5\u4ec5\u8bf4\u660e\u5b83\u53ea\u4f7f\u7528\u4e00\u4e2aCPU\u6216\u4e00\u6761\u6536\u96c6\u7ebf\u7a0b\u53bb\u5b8c\u6210\u5783\u573e\u6536\u96c6\u5de5\u4f5c\uff0c\u66f4\u91cd\u8981\u7684\u662f\u5728\u5b83\u6536\u96c6\u5783\u573e\u65f6\uff0c\u5fc5\u987b\u6682\u505c\u5176\u4ed6\u6240\u6709\u5de5\u4f5c\u7ebf\u7a0b\uff0c\u77e5\u9053\u5b83\u6536\u96c6\u7ed3\u675f\u3002\uff08Stop-The-World\uff09<\/p>\n<h4>Serial \u6536\u96c6\u5668<\/h4>\n<p>\u9002\u7528\u4e8e\u65b0\u751f\u4ee3\u5783\u573e\u6536\u96c6\uff0c\u91c7\u53d6<strong>\u590d\u5236\u7b97\u6cd5<\/strong>\uff0c\u6682\u505c\u6240\u6709\u7528\u6237\u7ebf\u7a0b<\/p>\n<h4>Serial Old \u6536\u96c6\u5668<\/h4>\n<p>\u9002\u7528\u4e8e\u8001\u5e74\u4ee3\u5783\u573e\u6536\u96c6\uff0c\u91c7\u53d6<strong>\u6807\u8bb0-\u6574\u7406\u7b97\u6cd5<\/strong>\uff0c\u6682\u505c\u6240\u6709\u7528\u6237\u7ebf\u7a0b<br \/>\n<img decoding=\"async\" src=\"https:\/\/www.isvmspace.com\/wp-content\/uploads\/2023\/02\/\u5783\u573e\u6536\u96c6\u5668-\u4e32\u884c.png\" alt=\"\" \/><\/p>\n<h2>\u541e\u5410\u91cf\u4f18\u5148<\/h2>\n<h4>Parallel Scavenge \u6536\u96c6\u5668<\/h4>\n<p>\u9002\u7528\u4e8e\u65b0\u751f\u4ee3\u5783\u573e\u6536\u96c6\uff0c\u91c7\u53d6\u590d\u5236\u7b97\u6cd5\uff0c\u6682\u505c\u6240\u6709\u7528\u6237\u7ebf\u7a0b<\/p>\n<h4>Parallel Old \u6536\u96c6\u5668<\/h4>\n<p>\u9002\u7528\u4e8e\u8001\u5e74\u4ee3\u5783\u573e\u6536\u96c6\uff0c\u91c7\u53d6\u6807\u8bb0-\u6574\u7406\u7b97\u6cd5\uff0c\u6682\u505c\u6240\u6709\u7528\u6237\u7ebf\u7a0b<br \/>\n<img decoding=\"async\" src=\"https:\/\/www.isvmspace.com\/wp-content\/uploads\/2023\/02\/\u5783\u573e\u6536\u96c6\u5668-\u541e\u5410\u91cf\u4f18\u5148.png\" alt=\"\" \/><\/p>\n<pre><code class=\"language-txt line-numbers\">+XX:MaxGCPauseMills  \u63a7\u5236\u6700\u5927\u5783\u573e\u56de\u6536\u505c\u987f\u65f6\u95f4\n+XX:GCTimeRatio  \u5783\u573e\u6536\u96c6\u65f6\u95f4\u5360\u6bd41\/\uff081+ratio\uff09\n+XX:+UserAdaptiveSizePolicy  GC\u81ea\u9002\u5e94\u8c03\u6574\u7b56\u7565\n<\/code><\/pre>\n<h2>\u54cd\u5e94\u65f6\u95f4\u4f18\u5148<\/h2>\n<h4>CMS\uff08Concurrent Mark Sweep\uff09\u6536\u96c6\u5668<\/h4>\n<p>\u8fd9\u662f\u4e00\u79cd\u4ee5\u83b7\u53d6\u6700\u77ed\u56de\u6536\u505c\u987f\u65f6\u95f4\u4e3a\u76ee\u6807\u7684\u6536\u96c6\u5668\u3002\u8be5\u6536\u96c6\u5668\u57fa\u4e8e\u6807\u8bb0-\u6e05\u9664\u7b97\u6cd5\u5b9e\u73b0\u3002<br \/>\n<img decoding=\"async\" src=\"https:\/\/www.isvmspace.com\/wp-content\/uploads\/2023\/02\/\u5783\u573e\u6536\u96c6\u5668-\u54cd\u5e94\u65f6\u95f4\u4f18\u5148.png\" alt=\"\" \/><br \/>\n\u521d\u59cb\u6807\u8bb0\uff08CMS initial mark\uff09: \u4ec5\u4ec5\u53ea\u662f\u6807\u8bb0\u4e00\u4e0bGC Roots\u80fd\u76f4\u63a5\u5173\u8054\u5230\u7684\u5bf9\u8c61\uff0c\u901f\u5ea6\u5f88\u5feb<\/p>\n<p>\u5e76\u53d1\u6807\u8bb0\uff08CMS concurrent mark\uff09: \u8fdb\u884cGC Roots tracing<\/p>\n<p>\u91cd\u65b0\u6807\u8bb0\uff08CMS remark\uff09:\u4fee\u6b63\u5e76\u53d1\u6807\u8bb0\u671f\u95f4\u56e0\u7528\u6237\u7a0b\u5e8f\u7ee7\u7eed\u8fd0\u4f5c\u800c\u5bfc\u81f4\u6807\u8bb0\u4ea7\u751f\u53d8\u52a8\u7684\u90a3\u4e00\u90e8\u5206\u5bf9\u8c61\u7684\u6807\u8bb0\u8bb0\u5f55<\/p>\n<p>\u5e76\u53d1\u6e05\u9664\uff08CMS concurrent sweep\uff09<\/p>\n<p><strong>\u4f18\u70b9\uff1a<\/strong><br \/>\n1.\u5e76\u53d1\u6536\u96c6<br \/>\n2.\u4f4e\u505c\u987f<br \/>\n<strong>\u7f3a\u70b9\uff1a<\/strong><br \/>\n1.\u5bf9CPU\u8d44\u6e90\u975e\u5e38\u654f\u611f<br \/>\n2.\u65e0\u6cd5\u5904\u7406\u6d6e\u52a8\u5783\u573e\uff08Floating Garbage\uff09\uff0c\u53ef\u80fd\u51fa\u73b0Concurrent Mode Failure\u5bfc\u81f4\u53e6\u4e00\u6b21Full GC<br \/>\n3.\u57fa\u4e8e\u6807\u8bb0-\u6e05\u9664\u7b97\u6cd5\u53ef\u80fd\u4ea7\u751f\u7a7a\u95f4\u788e\u7247<br \/>\n-XX:+UserCMSCompactAtFullCollection \u7528\u4e8e\u788e\u7247\u6574\u5408<br \/>\n-XX:CMSFullGCsBeforeCompaction=size \u7528\u4e8e\u6267\u884c\u591a\u5c11\u6b21\u4e0d\u538b\u7f29\u7684Full GC\u540e\uff0c\u8ddf\u7740\u6765\u4e00\u6b21\u788e\u7247\u6574\u5408\uff0c\u9ed8\u8ba4\u4e3a0<\/p>\n<h2>G1<\/h2>\n<h4>G1\uff08Garbage First\uff09\u6536\u96c6\u5668<\/h4>\n<p><strong>G1\u5185\u5b58\u6a21\u578b\uff1a<\/strong><br \/>\n\u5c06\u6574\u4e2aJava\u5806\u5212\u5206\u4e3a\u591a\u4e2a\u5927\u5c0f\u76f8\u7b49\u7684\u72ec\u7acb\u533a\u57df\uff08Region\uff09\uff0c\u6bcf\u4e2aRegion\u88ab\u6807\u8bb0\u4e86E\u3001S\u3001O\u548cH\uff08\u5de8\u578b\u5bf9\u8c61\uff1ahumongous object\uff0c\u7528\u4e8e\u5bb9\u7eb3\u5927\u5c0f\u4e3a\u6807\u51c6\u533a\u57df50%\u6216\u66f4\u5927\u7684\u5bf9\u8c61\uff09\u3002<br \/>\n\u5806\u5206\u4e3a\u5927\u7ea62000\u4e2aRegion\uff0c\u6bcf\u4e2aRegion\u6700\u5c0f\u4e3a1Mb\uff0c\u6700\u5927\u4e3a32Mb\u3002<br \/>\n-XX:G1HeapRegionSize\u53ef\u4ee5\u8bbe\u7f6eRegion\u5927\u5c0f\u3002<br \/>\n<img decoding=\"async\" src=\"https:\/\/www.isvmspace.com\/wp-content\/uploads\/2023\/02\/G1\u5185\u5b58\u6a21\u578b.png\" alt=\"\" \/><\/p>\n<p><strong>Young GC\uff1a<\/strong><br \/>\n\u53d1\u751f\u5728\u5e74\u8f7b\u4ee3\u7684GC\u7b97\u6cd5\uff0c\u4e00\u822c\u5bf9\u8c61\uff08\u9664\u4e86\u5de8\u578b\u5bf9\u8c61\uff09\u90fd\u662f\u5728Eden Region\u4e2d\u5206\u914d\u5185\u5b58\uff0c\u5f53\u6240\u6709Eden Region\u88ab\u8017\u5c3d\u65e0\u6cd5\u7533\u8bf7\u5185\u5b58\u65f6\uff0c\u5c31\u4f1a\u89e6\u53d1\u4e00\u6b21Young GC\uff0c\u6d3b\u8dc3\u5bf9\u8c61\u4f1a\u88ab\u62f7\u8d1d\u5230Survivor Region\u6216\u8005\u664b\u5347\u5230Old Region\u3002<br \/>\n<img decoding=\"async\" src=\"https:\/\/www.isvmspace.com\/wp-content\/uploads\/2023\/02\/G1-ygc.png\" alt=\"\" \/><\/p>\n<p><strong>Mixed GC\uff1a<\/strong><br \/>\n\u5f53\u8d8a\u6765\u8d8a\u591a\u7684\u5bf9\u8c61\u664b\u5347\u5230\u8001\u5e74\u4ee3Old Region\u65f6\uff0c\u4e3a\u4e86\u907f\u514d\u5806\u5185\u5b58\u88ab\u8017\u5c3d\uff0c\u865a\u62df\u673a\u4f1a\u89e6\u53d1Mixed GC\uff0c\u9664\u4e86\u56de\u6536\u6574\u4e2aYoung Region\uff0c\u8fd8\u4f1a\u56de\u6536\u4e00\u90e8\u5206\u7684Old Region\u3002<br \/>\n<img decoding=\"async\" src=\"https:\/\/www.isvmspace.com\/wp-content\/uploads\/2023\/02\/G1-mixedgc.png\" alt=\"\" \/><\/p>\n<p><strong>\u5927\u81f4\u6b65\u9aa4<\/strong><br \/>\n<img decoding=\"async\" src=\"https:\/\/www.isvmspace.com\/wp-content\/uploads\/2023\/02\/G1\u6536\u96c6\u6b65\u9aa4.png\" alt=\"\" \/><br \/>\n1.\u5e76\u521d\u59cb\u6807\u8bb0\uff08 Initial marking\uff09<br \/>\n\u4ec5\u4ec5\u53ea\u662f\u6807\u8bb0\u4e00\u4e0bGC Roots\u80fd\u76f4\u63a5\u5173\u8054\u5230\u7684\u5bf9\u8c61\uff0c\u5e76\u4e14\u4fee\u6539TAMS\uff08Next Top at Mark Start\uff09\u7684\u503c\uff0c\u4f1a\u89e6\u53d1STW\uff0c\u8017\u65f6\u5f88\u77ed<br \/>\n2.\u5e76\u53d1\u6807\u8bb0\uff08Concurrent marking\uff09<br \/>\n\u8fdb\u884cGC Roots tracing<br \/>\n3.\u6700\u7ec8\u6807\u8bb0\uff08Remark\uff09<br \/>\n\u4fee\u6b63\u5e76\u53d1\u6807\u8bb0\u671f\u95f4\u56e0\u7528\u6237\u7a0b\u5e8f\u7ee7\u7eed\u8fd0\u4f5c\u800c\u5bfc\u81f4\u6807\u8bb0\u4ea7\u751f\u53d8\u52a8\u7684\u90a3\u4e00\u90e8\u5206\u5bf9\u8c61\u7684\u6807\u8bb0\u8bb0\u5f55\uff0c<br \/>\n\u865a\u62df\u673a\u5c06\u8fd9\u6bb5\u65f6\u95f4\u5bf9\u8c61\u53d8\u5316\u8bb0\u5f55\u5728\u7ebf\u7a0bRemembered Set Logs\uff0c\u5728\u6700\u7ec8\u9636\u6bb5\u9700\u8981\u628aRemembered Set Logs\u7684\u6570\u636e\u5408\u5e76\u5230Remembered Set\u4e2d<br \/>\n4.\u590d\u5236\u6e05\u7406\uff08Copying\/Cleanup\uff09<br \/>\n\u53ea\u9009\u62e9\u5783\u573e\u8f83\u591a\u7684\u533a\u57df<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u5206\u7c7b \u4e32\u884c \u4e0d\u4ec5\u4ec5\u8bf4\u660e\u5b83\u53ea\u4f7f\u7528\u4e00\u4e2aCPU\u6216\u4e00\u6761\u6536\u96c6\u7ebf\u7a0b\u53bb\u5b8c\u6210\u5783\u573e\u6536\u96c6\u5de5\u4f5c\uff0c\u66f4\u91cd\u8981\u7684\u662f\u5728\u5b83\u6536\u96c6\u5783\u573e\u65f6\uff0c\u5fc5\u987b\u6682\u505c\u5176 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[16],"tags":[],"_links":{"self":[{"href":"https:\/\/www.isvmspace.com\/index.php?rest_route=\/wp\/v2\/posts\/176"}],"collection":[{"href":"https:\/\/www.isvmspace.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.isvmspace.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.isvmspace.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.isvmspace.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=176"}],"version-history":[{"count":1,"href":"https:\/\/www.isvmspace.com\/index.php?rest_route=\/wp\/v2\/posts\/176\/revisions"}],"predecessor-version":[{"id":185,"href":"https:\/\/www.isvmspace.com\/index.php?rest_route=\/wp\/v2\/posts\/176\/revisions\/185"}],"wp:attachment":[{"href":"https:\/\/www.isvmspace.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=176"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.isvmspace.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=176"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.isvmspace.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=176"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}