private static void OptimizeTwo() { int M = 1024 * 1024; byte[] b1 = new byte[3 * M]; // 3M
} GC Log: Heap PSYoungGen total 6144K, used 4914K [0x00000007bf980000, 0x00000007c0000000, 0x00000007c0000000) eden space 5632K, 87% used [0x00000007bf980000,0x00000007bfe4c8e8,0x00000007bff00000) from space 512K, 0% used [0x00000007bff80000,0x00000007bff80000,0x00000007c0000000) to space 512K, 0% used [0x00000007bff00000,0x00000007bff00000,0x00000007bff80000) ParOldGen total 13824K, used 0K [0x00000007bec00000, 0x00000007bf980000, 0x00000007bf980000) object space 13824K, 0% used [0x00000007bec00000,0x00000007bec00000,0x00000007bf980000) Metaspace used 3045K, capacity 4496K, committed 4864K, reserved 1056768K class space used 334K, capacity 388K, committed 512K, reserved 1048576K
private static void OptimizeTwo() { int M = 1024 * 1024; byte[] b1 = new byte[3 * M]; // 3M
} GC Log: Heap par new generation total 6144K, used 1947K [0x00000007bec00000, 0x00000007bf2a0000, 0x00000007bf2a0000) eden space 5504K, 35% used [0x00000007bec00000, 0x00000007bede6e40, 0x00000007bf160000) from space 640K, 0% used [0x00000007bf160000, 0x00000007bf160000, 0x00000007bf200000) to space 640K, 0% used [0x00000007bf200000, 0x00000007bf200000, 0x00000007bf2a0000) tenured generation total 13696K, used 3072K [0x00000007bf2a0000, 0x00000007c0000000, 0x00000007c0000000) the space 13696K, 22% used [0x00000007bf2a0000, 0x00000007bf5a0010, 0x00000007bf5a0200, 0x00000007c0000000) Metaspace used 3045K, capacity 4496K, committed 4864K, reserved 1056768K class space used 334K, capacity 388K, committed 512K, reserved 1048576K
JVM 参数:-Xmx20M -Xms20M -Xmn10M -XX:+PrintGCDetails private static void OptimizeThree() { int M = 1024 * 1024; byte[] b1 = new byte[2 * M]; // 2M byte[] b2 = new byte[2 * M]; byte[] b4 = new byte[2 * M]; b4 = null; byte[] b5 = new byte[2 * M]; byte[] b6 = new byte[2 * M];
} GC Log: [GC (Allocation Failure) [PSYoungGen: 3891K-496K(6144K)] 3891K-2640K(19968K), 0.0031407 secs] [Times: user=0.01 sys=0.01, real=0.00 secs] [GC (Allocation Failure) [PSYoungGen: 4756K-496K(6144K)] 6900K-4712K(19968K), 0.0030381 secs] [Times: user=0.01 sys=0.00, real=0.00 secs] Heap PSYoungGen total 6144K, used 4775K [0x00000007bf980000, 0x00000007c0000000, 0x00000007c0000000) eden space 5632K, 75% used [0x00000007bf980000,0x00000007bfdadd80,0x00000007bff00000) from space 512K, 96% used [0x00000007bff80000,0x00000007bfffc010,0x00000007c0000000) to space 512K, 0% used [0x00000007bff00000,0x00000007bff00000,0x00000007bff80000) ParOldGen total 13824K, used 4216K [0x00000007bec00000, 0x00000007bf980000, 0x00000007bf980000) object space 13824K, 30% used [0x00000007bec00000,0x00000007bf01e020,0x00000007bf980000) Metaspace used 3165K, capacity 4496K, committed 4864K, reserved 1056768K class space used 345K, capacity 388K, committed 512K, reserved 1048576K
JVM 参数:-Xmx20M -Xms20M -Xmn10M -XX:+PrintGCDetails -XX:MaxTenuringThreshold=1 private static void OptimizeThree() { int M = 1024 * 1024; byte[] b1 = new byte[2 * M]; // 2M byte[] b2 = new byte[2 * M]; byte[] b4 = new byte[2 * M]; b4 = null; byte[] b5 = new byte[2 * M]; byte[] b6 = new byte[2 * M];
}
GC Log: [GC (Allocation Failure) [PSYoungGen: 4123K-512K(6144K)] 4123K-2648K(19968K), 0.0033229 secs] [Times: user=0.01 sys=0.00, real=0.00 secs] [GC (Allocation Failure) [PSYoungGen: 4770K-32K(6144K)] 6906K-4692K(19968K), 0.0037061 secs] [Times: user=0.01 sys=0.00, real=0.00 secs] Heap PSYoungGen total 6144K, used 4309K [0x00000007bf980000, 0x00000007c0000000, 0x00000007c0000000) eden space 5632K, 75% used [0x00000007bf980000,0x00000007bfdad6d0,0x00000007bff00000) from space 512K, 6% used [0x00000007bff80000,0x00000007bff88000,0x00000007c0000000) to space 512K, 0% used [0x00000007bff00000,0x00000007bff00000,0x00000007bff80000) ParOldGen total 13824K, used 4660K [0x00000007bec00000, 0x00000007bf980000, 0x00000007bf980000) object space 13824K, 33% used [0x00000007bec00000,0x00000007bf08d310,0x00000007bf980000) Metaspace used 3204K, capacity 4496K, committed 4864K, reserved 1056768K class space used 350K, capacity 388K, committed 512K, reserved 1048576K