JVM gc只新生代串行GC
2011-09-16 20:43
106 查看
1.代码一:
执行:java -Xms20M -Xmx20M -Xmn10M -XX:+UseSerialGC -XX:+PrintHeapAtGC -Xloggc:gc.log JVMTest
gc两次:
java -Xms20M -Xmx20M -Xmn10M -XX:+UseSerialGC -XX:+PrintHeapAtGC -Xloggc:gc.log JVMTest
1次minor gc 一次full gc:原因 minor gc晋升到旧生代的大小大于旧生代的剩余空间。
新生代对象晋升到旧生代的规则:经过多次minor gc之后还存在的对象或者是to space放不下的直接晋升到old generation
public class JVMTest { public static void main(String args[]) throws InterruptedException { byte [] bytes1 = new byte[1024*1024*2]; byte [] bytes2 = new byte[1024*1024*2]; byte [] bytes3 = new byte[1024*1024*4]; Thread.sleep(2000); byte [] bytes4 = new byte[1024*1024*4]; Thread.sleep(2000); } }
执行:java -Xms20M -Xmx20M -Xmn10M -XX:+UseSerialGC -XX:+PrintHeapAtGC -Xloggc:gc.log JVMTest
gc两次:
{Heap before GC invocations=0 (full 0): def new generation total 9216K, used 5287K [7f9a00000, 7fa400000, 7fa400000) eden space 8192K, 64% used [7f9a00000, 7f9f29c78, 7fa200000) from space 1024K, 0% used [7fa200000, 7fa200000, 7fa300000) to space 1024K, 0% used [7fa300000, 7fa300000, 7fa400000) tenured generation total 10240K, used 0K [7fa400000, 7fae00000, 7fae00000) the space 10240K, 0% used [7fa400000, 7fa400000, 7fa400200, 7fae00000) compacting perm gen total 21248K, used 4813K [7fae00000, 7fc2c0000, 800000000) the space 21248K, 22% used [7fae00000, 7fb2b3628, 7fb2b3800, 7fc2c0000) No shared spaces configured. 0.904: [GC 5287K->4447K(19456K), 0.0315833 secs] Heap after GC invocations=1 (full 0): def new generation total 9216K, used 351K [7f9a00000, 7fa400000, 7fa400000) eden space 8192K, 0% used [7f9a00000, 7f9a00000, 7fa200000) from space 1024K, 34% used [7fa300000, 7fa357ed8, 7fa400000) to space 1024K, 0% used [7fa200000, 7fa200000, 7fa300000) tenured generation total 10240K, used 4096K [7fa400000, 7fae00000, 7fae00000) the space 10240K, 40% used [7fa400000, 7fa800020, 7fa800200, 7fae00000) compacting perm gen total 21248K, used 4813K [7fae00000, 7fc2c0000, 800000000) the space 21248K, 22% used [7fae00000, 7fb2b3628, 7fb2b3800, 7fc2c0000) No shared spaces configured. } {Heap before GC invocations=1 (full 0): def new generation total 9216K, used 4711K [7f9a00000, 7fa400000, 7fa400000) eden space 8192K, 53% used [7f9a00000, 7f9e41eb0, 7fa200000) from space 1024K, 34% used [7fa300000, 7fa357ed8, 7fa400000) to space 1024K, 0% used [7fa200000, 7fa200000, 7fa300000) tenured generation total 10240K, used 4096K [7fa400000, 7fae00000, 7fae00000) the space 10240K, 40% used [7fa400000, 7fa800020, 7fa800200, 7fae00000) compacting perm gen total 21248K, used 4817K [7fae00000, 7fc2c0000, 800000000) the space 21248K, 22% used [7fae00000, 7fb2b4498, 7fb2b4600, 7fc2c0000) No shared spaces configured. 2.940: [GC 8807K->8537K(19456K), 0.0193472 secs] Heap after GC invocations=2 (full 0): def new generation total 9216K, used 345K [7f9a00000, 7fa400000, 7fa400000) eden space 8192K, 0% used [7f9a00000, 7f9a00000, 7fa200000) from space 1024K, 33% used [7fa200000, 7fa2566e8, 7fa300000) to space 1024K, 0% used [7fa300000, 7fa300000, 7fa400000) tenured generation total 10240K, used 8192K [7fa400000, 7fae00000, 7fae00000) the space 10240K, 80% used [7fa400000, 7fac00030, 7fac00200, 7fae00000) compacting perm gen total 21248K, used 4817K [7fae00000, 7fc2c0000, 800000000) the space 21248K, 22% used [7fae00000, 7fb2b4498, 7fb2b4600, 7fc2c0000) No shared spaces configured. }2.代码2:
public class JVMTest { public static void main(String args[]) throws InterruptedException { byte [] bytes1 = new byte[1024*1024*2]; byte [] bytes2 = new byte[1024*1024*2]; byte [] bytes3 = new byte[1024*1024*2]; System.out.println("step 1"); byte [] bytes4 = new byte[1024*1024*2]; Thread.sleep(2000); System.out.println("step 2"); byte [] bytes5 = new byte[1024*1024*2]; byte [] bytes6 = new byte[1024*1024*2]; System.out.println("step 3"); byte [] bytes7 = new byte[1024*1024*2]; Thread.sleep(2000); } }
java -Xms20M -Xmx20M -Xmn10M -XX:+UseSerialGC -XX:+PrintHeapAtGC -Xloggc:gc.log JVMTest
1次minor gc 一次full gc:原因 minor gc晋升到旧生代的大小大于旧生代的剩余空间。
{Heap before GC invocations=0 (full 0): def new generation total 9216K, used 7335K [7f9a00000, 7fa400000, 7fa400000) eden space 8192K, 89% used [7f9a00000, 7fa129c88, 7fa200000) from space 1024K, 0% used [7fa200000, 7fa200000, 7fa300000) to space 1024K, 0% used [7fa300000, 7fa300000, 7fa400000) tenured generation total 10240K, used 0K [7fa400000, 7fae00000, 7fae00000) the space 10240K, 0% used [7fa400000, 7fa400000, 7fa400200, 7fae00000) compacting perm gen total 21248K, used 4814K [7fae00000, 7fc2c0000, 800000000) the space 21248K, 22% used [7fae00000, 7fb2b38c0, 7fb2b3a00, 7fc2c0000) No shared spaces configured. 1.019: [GC 7335K->6495K(19456K), 0.0418591 secs] Heap after GC invocations=1 (full 0): def new generation total 9216K, used 351K [7f9a00000, 7fa400000, 7fa400000) eden space 8192K, 0% used [7f9a00000, 7f9a00000, 7fa200000) from space 1024K, 34% used [7fa300000, 7fa357ed8, 7fa400000) to space 1024K, 0% used [7fa200000, 7fa200000, 7fa300000) tenured generation total 10240K, used 6144K [7fa400000, 7fae00000, 7fae00000) the space 10240K, 60% used [7fa400000, 7faa00030, 7faa00200, 7fae00000) compacting perm gen total 21248K, used 4814K [7fae00000, 7fc2c0000, 800000000) the space 21248K, 22% used [7fae00000, 7fb2b38c0, 7fb2b3a00, 7fc2c0000) No shared spaces configured. } {Heap before GC invocations=1 (full 0): def new generation total 9216K, used 6754K [7f9a00000, 7fa400000, 7fa400000) eden space 8192K, 78% used [7f9a00000, 7fa040af0, 7fa200000) from space 1024K, 34% used [7fa300000, 7fa357ed8, 7fa400000) to space 1024K, 0% used [7fa200000, 7fa200000, 7fa300000) tenured generation total 10240K, used 6144K [7fa400000, 7fae00000, 7fae00000) the space 10240K, 60% used [7fa400000, 7faa00030, 7faa00200, 7fae00000) compacting perm gen total 21248K, used 4817K [7fae00000, 7fc2c0000, 800000000) the space 21248K, 22% used [7fae00000, 7fb2b47b0, 7fb2b4800, 7fc2c0000) No shared spaces configured. 3.073: [Full GC 12898K->12633K(19456K), 0.0712905 secs] Heap after GC invocations=2 (full 1): def new generation total 9216K, used 4441K [7f9a00000, 7fa400000, 7fa400000) eden space 8192K, 54% used [7f9a00000, 7f9e56680, 7fa200000) from space 1024K, 0% used [7fa300000, 7fa300000, 7fa400000) to space 1024K, 0% used [7fa200000, 7fa200000, 7fa300000) tenured generation total 10240K, used 8192K [7fa400000, 7fae00000, 7fae00000) the space 10240K, 80% used [7fa400000, 7fac000c8, 7fac00200, 7fae00000) compacting perm gen total 21248K, used 4817K [7fae00000, 7fc2c0000, 800000000) the space 21248K, 22% used [7fae00000, 7fb2b47b0, 7fb2b4800, 7fc2c0000) No shared spaces configured. }
新生代对象晋升到旧生代的规则:经过多次minor gc之后还存在的对象或者是to space放不下的直接晋升到old generation
相关文章推荐
- java 虚拟机--新生代与老年代GC
- 在JVM中,新生代和旧生代有何区别?GC的回收方式有几种?server和client有和区别?
- Full GC为什么那么慢?为什么老年代垃圾回收效率比新生代低很多?为什么Minor gc速度比Major GC慢?
- 在JVM中,新生代和旧生代有何区别?GC的回收方式有几种?server和client有和区别?
- 在JVM中,新生代和旧生代有何区别?GC的回收方式有几种?server和client有和区别?
- Java GC、新生代、老年代
- JVM GC 算法和相关GC收集器
- java 虚拟机--新生代与老年代GC
- Java GC、新生代、老年代
- GC 垃圾回收算法,新生代,老年代,持久代
- JVM学习-----java7与Java8新生代GC发生了什么
- Java GC、新生代、老年代
- Java GC、新生代、老年代
- java 虚拟机--新生代与老年代GC [转]
- JAVA虚拟机:新生代和老年代GC
- 堆:新生代、老年代 以及minor GC 、full GC
- JVM如何GC,新生代,老年代,持久代,都存储哪些东西
- JAVA虚拟机:新生代和老年代GC
- Java GC、新生代、老年代
- java 虚拟机--新生代与老年代GC