-XX:SurvivorRatio 逃离我推掉我的手 2024-03-17 17:54 18阅读 0赞 **`-XXSurvivorRatio = eden :from = eden :to`** 。 **默认`-XXSurvivorRatio=8`,即 Eden : s0 : s1 = 8 : 1 : 1,Eden占了年轻代的8/10,不建议修改** -------------------- #### case1: `-XX:NewRatio=4 -XX:SurvivorRatio=8` #### <table> <thead> <tr> <th align="left">启动参数</th> </tr> </thead> <tbody> <tr> <td align="left">-Xmx200m -Xms100m <code>-XX:NewRatio=4 -XX:SurvivorRatio=8</code> -XX:+PrintCommandLineFlags</td> </tr> <tr> <td align="left"></td> </tr> <tr> <td align="left"><strong>启动日志</strong></td> </tr> <tr> <td align="left">-XX:ConcGCThreads=3 -XX:G1ConcRefinementThreads=13 -XX:GCDrainStackTargetSize=64 <code>-XX:InitialHeapSize=104857600</code> -XX:MarkStackSize=4194304 <code>-XX:MaxHeapSize=209715200</code> -XX:MinHeapSize=104857600 <code>-XX:NewRatio=4</code> -XX:+PrintCommandLineFlags -XX:ReservedCodeCacheSize=251658240 -XX:+SegmentedCodeCache <code>-XX:SurvivorRatio=8</code> -XX:+UseCompressedClassPointers -XX:+UseCompressedOops -XX:+UseG1GC -XX:-UseLargePagesIndividualAllocation</td> </tr> <tr> <td align="left"></td> </tr> <tr> <td align="left"><strong>JPS+jhsdb jmap --heap --pid 进程ID</strong></td> </tr> <tr> <td align="left">Heap Configuration:<br> MinHeapFreeRatio = 40<br> MaxHeapFreeRatio = 70<br> MaxHeapSize = 209715200 (200.0MB)<br> NewSize = 1363144 (1.2999954223632812MB)<br> MaxNewSize = 41943040 (40.0MB)<br> OldSize = 5452592 (5.1999969482421875MB)<br> NewRatio = 4<br> SurvivorRatio = 8<br> MetaspaceSize = 22020096 (21.0MB)<br> CompressedClassSpaceSize = 1073741824 (1024.0MB)<br> MaxMetaspaceSize = 17592186044415 MB<br> G1HeapRegionSize = 1048576 (1.0MB)</td> </tr> </tbody> </table> #### case 2 : `-Xmn80m -XX:SurvivorRatio=8` #### <table> <thead> <tr> <th align="left">启动参数</th> </tr> </thead> <tbody> <tr> <td align="left">-Xmx200m -Xms100m <code>-Xmn80m -XX:SurvivorRatio=8</code> -XX:+PrintCommandLineFlags</td> </tr> <tr> <td align="left"></td> </tr> <tr> <td align="left"><strong>启动日志</strong></td> </tr> <tr> <td align="left">-XX:ConcGCThreads=3 -XX:G1ConcRefinementThreads=13 -XX:GCDrainStackTargetSize=64 <code>-XX:InitialHeapSize=104857600</code> -XX:MarkStackSize=4194304 <code>-XX:MaxHeapSize=209715200</code> <code>-XX:MaxNewSize=83886080</code> -XX:MinHeapSize=104857600 <code>-XX:NewSize=83886080</code> -XX:+PrintCommandLineFlags -XX:ReservedCodeCacheSize=251658240 -XX:+SegmentedCodeCache -XX:SurvivorRatio=8 -XX:+UseCompressedClassPointers -XX:+UseCompressedOops -XX:+UseG1GC -XX:-UseLargePagesIndividualAllocation</td> </tr> <tr> <td align="left"></td> </tr> <tr> <td align="left"><strong>JPS+jhsdb jmap --heap --pid 进程ID</strong></td> </tr> <tr> <td align="left">Heap Configuration:<br> MinHeapFreeRatio = 40<br> MaxHeapFreeRatio = 70<br> MaxHeapSize = 209715200 (200.0MB)<br> NewSize = 83886080 (80.0MB)<br> MaxNewSize = 83886080 (80.0MB)<br> OldSize = 5452592 (5.1999969482421875MB)<br> NewRatio = 2<br> SurvivorRatio = 8<br> MetaspaceSize = 22020096 (21.0MB)<br> CompressedClassSpaceSize = 1073741824 (1024.0MB)<br> MaxMetaspaceSize = 17592186044415 MB<br> G1HeapRegionSize = 1048576 (1.0MB)</td> </tr> </tbody> </table> -------------------- ## 好早以前验证截图,删除可惜保留参考 ## #### case1: `-XX:NewRatio=4 -XX:SurvivorRatio=8` #### //JVM 启动参数 -Xmx40m -Xms20m -XX:NewRatio=4 -XX:SurvivorRatio=8 -XX:+PrintGCDetails -XX:+PrintCommandLineFlags //运行结果: -XX:InitialHeapSize=20971520 -XX:MaxHeapSize=41943040 -XX:NewRatio=4 -XX:+PrintCommandLineFlags -XX:+PrintGCDetails -XX:SurvivorRatio=8 -XX:+UseCompressedClassPointers -XX:+UseCompressedOops -XX:-UseLargePagesIndividualAllocation -XX:+UseParallelGC ![在这里插入图片描述][watermark_type_ZHJvaWRzYW5zZmFsbGJhY2s_shadow_50_text_Q1NETiBA5byg57Sr5aiD_size_20_color_FFFFFF_t_70_g_se_x_16] ![在这里插入图片描述][watermark_type_ZHJvaWRzYW5zZmFsbGJhY2s_shadow_50_text_Q1NETiBA5byg57Sr5aiD_size_20_color_FFFFFF_t_70_g_se_x_16 1] #### case 2 : `-Xmn80m -XX:SurvivorRatio=8` #### //JVM 启动参数 -Xmx400m -Xms200m -Xmn100m -XX:SurvivorRatio=8 -XX:+PrintGCDetails -XX:+PrintCommandLineFlags //运行结果: -XX:InitialHeapSize=20,971,520 -XX:MaxHeapSize=41,943,040 -XX:MaxNewSize=104,857,600 -XX:NewSize=104,857,600 -XX:+PrintCommandLineFlags -XX:+PrintGCDetails -XX:SurvivorRatio=8 -XX:+UseCompressedClassPointers -XX:+UseCompressedOops -XX:-UseLargePagesIndividualAllocation -XX:+UseParallelGC ![在这里插入图片描述][watermark_type_ZHJvaWRzYW5zZmFsbGJhY2s_shadow_50_text_Q1NETiBA5byg57Sr5aiD_size_20_color_FFFFFF_t_70_g_se_x_16 2] #### case 3 : -Xmn + -XX:SurvivorRatio & -Xmn > -Xmx #### //JVM 启动参数 -Xmx40m -Xms20m -Xmn100m -XX:SurvivorRatio=8 -XX:+PrintGCDetails -XX:+PrintCommandLineFlags //运行结果: -XX:InitialHeapSize=20,971,520 -XX:MaxHeapSize=41,943,040 -XX:MaxNewSize=104,857,600 -XX:NewSize=104,857,600 -XX:+PrintCommandLineFlags -XX:+PrintGCDetails -XX:SurvivorRatio=8 -XX:+UseCompressedClassPointers -XX:+UseCompressedOops -XX:-UseLargePagesIndividualAllocation -XX:+UseParallelGC ![在这里插入图片描述][watermark_type_ZHJvaWRzYW5zZmFsbGJhY2s_shadow_50_text_Q1NETiBA5byg57Sr5aiD_size_20_color_FFFFFF_t_70_g_se_x_16 3] [watermark_type_ZHJvaWRzYW5zZmFsbGJhY2s_shadow_50_text_Q1NETiBA5byg57Sr5aiD_size_20_color_FFFFFF_t_70_g_se_x_16]: https://image.dandelioncloud.cn/pgy_files/images/2024/03/15/936420f5326546118fe87ff95f1093ab.png [watermark_type_ZHJvaWRzYW5zZmFsbGJhY2s_shadow_50_text_Q1NETiBA5byg57Sr5aiD_size_20_color_FFFFFF_t_70_g_se_x_16 1]: https://image.dandelioncloud.cn/pgy_files/images/2024/03/15/38e1cb8a1e554056be47bb5c3313b16e.png [watermark_type_ZHJvaWRzYW5zZmFsbGJhY2s_shadow_50_text_Q1NETiBA5byg57Sr5aiD_size_20_color_FFFFFF_t_70_g_se_x_16 2]: https://image.dandelioncloud.cn/pgy_files/images/2024/03/15/8a0eb9f1b6e544dba0c67b716db4b783.png [watermark_type_ZHJvaWRzYW5zZmFsbGJhY2s_shadow_50_text_Q1NETiBA5byg57Sr5aiD_size_20_color_FFFFFF_t_70_g_se_x_16 3]: https://image.dandelioncloud.cn/pgy_files/images/2024/03/15/b19fcaede5514c838e6ff1912325f450.png
还没有评论,来说两句吧...