jvm eden space 为什么会为 0K - V2EX
请不要在回答技术问题时复制粘贴 AI 生成的内容
sun1992

jvm eden space 为什么会为 0K

  •  
  •   sun1992 Nov 9, 2017 2774 views
    This topic created in 3130 days ago, the information mentioned may be changed or developed.

    设置新生代大小为 1M,-XX:SurvivorRatio=2, 结果 eden space 为 0K,from space 为 512K,to space 为 512K。是因为 from 和 to 有最小值限制吗?不太明白,求各位大佬指教~

    vm 参数: -Xmx20m -Xms20m -Xmn1m -XX:SurvivorRatio=2 -XX:+PrintGCDetails

    版本:jdk1.7.0_79

    代码和结果如下:

    public class NewSizeDemo { public static void main(String[] args){ byte[] b = null; for (int i=0; i<10; i++){ b = new byte[1*1024*1024]; } } } Heap PSYoungGen total 512K, used 0K [0x00000007fff00000, 0x0000000800000000, 0x0000000800000000) eden space 0K, -2147483648% used [0x00000007fff00000,0x00000007fff00000,0x00000007fff00000) from space 512K, 0% used [0x00000007fff80000,0x00000007fff80000,0x0000000800000000) to space 512K, 0% used [0x00000007fff00000,0x00000007fff00000,0x00000007fff80000) ParOldGen total 19456K, used 11573K [0x00000007fec00000, 0x00000007fff00000, 0x00000007fff00000) object space 19456K, 59% used [0x00000007fec00000,0x00000007ff74d5a0,0x00000007fff00000) PSPermGen total 21504K, used 2996K [0x00000007f9a00000, 0x00000007faf00000, 0x00000007fec00000) object space 21504K, 13% used [0x00000007f9a00000,0x00000007f9ced030,0x00000007faf00000) 
    2 replies    2017-11-10 11:26:33 +08:00
    sun1992
        1
    sun1992  
    OP
       Nov 9, 2017
    详细参数
    -XX:InitialHeapSize=20971520 -XX:MaxHeapSize=20971520 XX:MaxNewSize=1048576 -XX:NewSize=1048576 -XX:+PrintCommandLineFlags -XX:+PrintGCDetails -XX:SurvivorRatio=2 -XX:+UseCompressedOops -XX:+UseParallelGC
    sun1992
        2
    sun1992  
    OP
       Nov 10, 2017
    这个是 jdk7u40 版本左右开始的 bug,jdk8 中已经修复

    http://www.oracle.com/technetwork/java/javase/7u40-relnotes-2004172.html
    jdk7u40 的 Update Release Notes 中有这个问题说明

    ````
    Area: hotspot/gc
    Synopsis: New minimum young generation size is not properly checked by the JVM.

    In JDK 7u40, the minimum size of the young generation for the parallel garbage collector was increased from 192 KB to 768 KB in a 32-bit JVM, and to 1536 KB in a 64-bit JVM. This new minimum size is not properly checked by the JVM. If a young generation size that is smaller than the new minimum is specified on the command line, it can result in either a crash or degraded performance.

    The young generation size is set by the options -XX:NewSize= and -XX:MaxNewSize=, or by the option -Xmn (the latter option is equivalent to setting both NewSize and MaxNewSize to ). If the above options are not used, then the young generation size is computed as a fraction of the maximum heap size.

    Workaround: Use a young generation size that is at least 768 KB (for 32-bit JVM) or 1536 KB (for 64-bit JVM).
    ````
    About     Help     Advertise     Blog     API     FAQ     Solana     935 Online   Highest 6679       Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 30ms UTC 22:05 PVG 06:05 LAX 15:05 JFK 18:05
    Do have faith in what you're doing.
    ubao msn snddm index pchome yahoo rakuten mypaper meadowduck bidyahoo youbao zxmzxm asda bnvcg cvbfg dfscv mmhjk xxddc yybgb zznbn ccubao uaitu acv GXCV ET GDG YH FG BCVB FJFH CBRE CBC GDG ET54 WRWR RWER WREW WRWER RWER SDG EW SF DSFSF fbbs ubao fhd dfg ewr dg df ewwr ewwr et ruyut utut dfg fgd gdfgt etg dfgt dfgd ert4 gd fgg wr 235 wer3 we vsdf sdf gdf ert xcv sdf rwer hfd dfg cvb rwf afb dfh jgh bmn lgh rty gfds cxv xcv xcs vdas fdf fgd cv sdf tert sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf shasha9178 shasha9178 shasha9178 shasha9178 shasha9178 liflif2 liflif2 liflif2 liflif2 liflif2 liblib3 liblib3 liblib3 liblib3 liblib3 zhazha444 zhazha444 zhazha444 zhazha444 zhazha444 dende5 dende denden denden2 denden21 fenfen9 fenf619 fen619 fenfe9 fe619 sdf sdf sdf sdf sdf zhazh90 zhazh0 zhaa50 zha90 zh590 zho zhoz zhozh zhozho zhozho2 lislis lls95 lili95 lils5 liss9 sdf0ty987 sdft876 sdft9876 sdf09876 sd0t9876 sdf0ty98 sdf0976 sdf0ty986 sdf0ty96 sdf0t76 sdf0876 df0ty98 sf0t876 sd0ty76 sdy76 sdf76 sdf0t76 sdf0ty9 sdf0ty98 sdf0ty987 sdf0ty98 sdf6676 sdf876 sd876 sd876 sdf6 sdf6 sdf9876 sdf0t sdf06 sdf0ty9776 sdf0ty9776 sdf0ty76 sdf8876 sdf0t sd6 sdf06 s688876 sd688 sdf86