packagelddxfs.jvm.heap;/*** Author:lddxfs(lddxfs@qq.com;https://www.cnblogs.com/LDDXFS/)
* Date:2018/10/15*/
public classXmn {//-Xms20m -Xmx20m -Xmn1m -XX:+PrintGCDetails//指定最小堆 最大堆 设置新生代大小 打印GC详细//-XX:NewRatio//新生代(eden+2*s)和老年代(不包含永久区)的比值//4 表示 新生代:老年代 =1:4 即年轻代占的1/5//-XX:SurvivorRatio//设置两个Survivor(from to)区和edon的比//8 表示 两个Survivor:eden=2:8 ,即一个Survivor占年轻代的1/10
public static voidmain(String[] args) {byte[] b;for (int i = 0; i < 10; i++) {
b= new byte[1 * 1024 * 1024];
}
}/*** //-Xms20m -Xmx20m -Xmn1m -XX:+PrintGCDetails
* 指定最小堆20m,最大堆20m,设置新生代1m
* [GC (Allocation Failure) [PSYoungGen: 505K->488K(1024K)] 505K->512K(19968K), 0.0005177 secs] [Times: user=0.00 sys=0.00, real=0.00 secs]
* [GC (Allocation Failure) [PSYoungGen: 1000K->504K(1024K)] 1024K->660K(19968K), 0.0005936 secs] [Times: user=0.00 sys=0.00, real=0.00 secs]
* [GC (Allocation Failure) [PSYoungGen: 1004K->504K(1024K)] 1160K->724K(19968K), 0.0005464 secs] [Times: user=0.00 sys=0.00, real=0.00 secs]
* Heap
* PSYoungGen total 1024K, used 902K [0x00000000ffe80000, 0x0000000100000000, 0x0000000100000000)
* eden space 512K, 77% used [0x00000000ffe80000,0x00000000ffee3b00,0x00000000fff00000)
* from space 512K, 98% used [0x00000000fff00000,0x00000000fff7e010,0x00000000fff80000)
* to space 512K, 0% used [0x00000000fff80000,0x00000000fff80000,0x0000000100000000)
* ParOldGen total 18944K, used 10460K [0x00000000fec00000, 0x00000000ffe80000, 0x00000000ffe80000)
* object space 18944K, 55% used [0x00000000fec00000,0x00000000ff637100,0x00000000ffe80000)
* Metaspace used 3445K, capacity 4496K, committed 4864K, reserved 1056768K
* class space used 376K, capacity 388K, committed 512K, reserved 1048576K
* Java HotSpot(TM) 64-Bit Server VM warning: NewSize (1536k) is greater than the MaxNewSize (1024k). A new max generation size of 1536k will be used.
*
* Process finished with exit code 0*/
/*** //-Xms20m -Xmx20m -Xmn15m -XX:+PrintGCDetails
* 设置最小堆20m,最大堆20m,设置新生代15m, 打印GC详细
* [GC (Allocation Failure) [PSYoungGen: 11517K->856K(13824K)] 11517K->864K(18944K), 0.0014970 secs] [Times: user=0.00 sys=0.00, real=0.00 secs]
* Heap
* PSYoungGen total 13824K, used 2126K [0x00000000ff100000, 0x0000000100000000, 0x0000000100000000)
* eden space 12288K, 10% used [0x00000000ff100000,0x00000000ff23d8a0,0x00000000ffd00000)
* from space 1536K, 55% used [0x00000000ffd00000,0x00000000ffdd6030,0x00000000ffe80000)
* to space 1536K, 0% used [0x00000000ffe80000,0x00000000ffe80000,0x0000000100000000)
* ParOldGen total 5120K, used 8K [0x00000000fec00000, 0x00000000ff100000, 0x00000000ff100000)
* object space 5120K, 0% used [0x00000000fec00000,0x00000000fec02000,0x00000000ff100000)
* Metaspace used 3413K, capacity 4496K, committed 4864K, reserved 1056768K
* class space used 370K, capacity 388K, committed 512K, reserved 1048576K
*
* Process finished with exit code 0*/
/*** //-Xms20m -Xmx20m -Xmn7m -XX:+PrintGCDetails
* 设置最小堆20m,最大堆20m,设置新生代7m, 打印GC详细
* [GC (Allocation Failure) [PSYoungGen: 5163K->504K(6656K)] 5163K->712K(19968K), 0.0009239 secs] [Times: user=0.00 sys=0.00, real=0.00 secs]
* [GC (Allocation Failure) [PSYoungGen: 5803K->488K(6656K)] 6011K->808K(19968K), 0.0004184 secs] [Times: user=0.00 sys=0.00, real=0.00 secs]
* Heap
* PSYoungGen total 6656K, used 2748K [0x00000000ff900000, 0x0000000100000000, 0x0000000100000000)
* eden space 6144K, 36% used [0x00000000ff900000,0x00000000ffb35348,0x00000000fff00000)
* from space 512K, 95% used [0x00000000fff80000,0x00000000ffffa020,0x0000000100000000)
* to space 512K, 0% used [0x00000000fff00000,0x00000000fff00000,0x00000000fff80000)
* ParOldGen total 13312K, used 320K [0x00000000fec00000, 0x00000000ff900000, 0x00000000ff900000)
* object space 13312K, 2% used [0x00000000fec00000,0x00000000fec50010,0x00000000ff900000)
* Metaspace used 3420K, capacity 4496K, committed 4864K, reserved 1056768K
* class space used 371K, capacity 388K, committed 512K, reserved 1048576K
*
* Process finished with exit code 0*/
/*** //-Xms20m -Xmx20m -Xmn7m -XX:SurvivorRatio=2 -XX:+PrintGCDetails
* 设置最小堆20m,最大堆20m,设置新生代7m, 打印GC详细
* [GC (Allocation Failure) [PSYoungGen: 4069K->808K(5632K)] 4069K->816K(18944K), 0.0007074 secs] [Times: user=0.00 sys=0.00, real=0.00 secs]
* [GC (Allocation Failure) [PSYoungGen: 4000K->792K(5632K)] 4008K->800K(18944K), 0.0005794 secs] [Times: user=0.00 sys=0.00, real=0.00 secs]
* [GC (Allocation Failure) [PSYoungGen: 4043K->776K(5632K)] 4051K->784K(18944K), 0.0005552 secs] [Times: user=0.00 sys=0.00, real=0.00 secs]
* Heap
* PSYoungGen total 5632K, used 2955K [0x00000000ff900000, 0x0000000100000000, 0x0000000100000000)
* eden space 4096K, 53% used [0x00000000ff900000,0x00000000ffb20ea8,0x00000000ffd00000)
* from space 1536K, 50% used [0x00000000ffd00000,0x00000000ffdc2020,0x00000000ffe80000)
* to space 1536K, 0% used [0x00000000ffe80000,0x00000000ffe80000,0x0000000100000000)
* ParOldGen total 13312K, used 8K [0x00000000fec00000, 0x00000000ff900000, 0x00000000ff900000)
* object space 13312K, 0% used [0x00000000fec00000,0x00000000fec02000,0x00000000ff900000)
* Metaspace used 3425K, capacity 4496K, committed 4864K, reserved 1056768K
* class space used 372K, capacity 388K, committed 512K, reserved 1048576K
*
* Process finished with exit code 0*/
/*** //-Xms20m -Xms20m -XX:NewRatio=1 -XX:SurvivorRatio=2 -XX:+PrintGCDetails
* [GC (Allocation Failure) [PSYoungGen: 5058K->792K(7680K)] 5058K->800K(17920K), 0.0007751 secs] [Times: user=0.00 sys=0.00, real=0.00 secs]
* [GC (Allocation Failure) [PSYoungGen: 5038K->744K(7680K)] 5046K->752K(17920K), 0.0006721 secs] [Times: user=0.00 sys=0.00, real=0.00 secs]
* Heap
* PSYoungGen total 7680K, used 4095K [0x0000000740600000, 0x0000000741500000, 0x00000007c0000000)
* eden space 5120K, 65% used [0x0000000740600000,0x0000000740945bf0,0x0000000740b00000)
* from space 2560K, 29% used [0x0000000740d80000,0x0000000740e3a020,0x0000000741000000)
* to space 2560K, 0% used [0x0000000740b00000,0x0000000740b00000,0x0000000740d80000)
* ParOldGen total 10240K, used 8K [0x00000006c0c00000, 0x00000006c1600000, 0x0000000740600000)
* object space 10240K, 0% used [0x00000006c0c00000,0x00000006c0c02000,0x00000006c1600000)
* Metaspace used 3423K, capacity 4496K, committed 4864K, reserved 1056768K
* class space used 372K, capacity 388K, committed 512K, reserved 1048576K
*
* Process finished with exit code 0
**/
/*** //-Xms20m -Xms20m -XX:NewRatio=1 -XX:SurvivorRatio=8 -XX:+PrintGCDetails
*[GC (Allocation Failure) [PSYoungGen: 7296K->792K(9216K)] 7296K->800K(19456K), 0.0007097 secs] [Times: user=0.00 sys=0.00, real=0.00 secs]
* Heap
* PSYoungGen total 9216K, used 6234K [0x0000000740600000, 0x0000000741000000, 0x00000007c0000000)
* eden space 8192K, 66% used [0x0000000740600000,0x0000000740b509e8,0x0000000740e00000)
* from space 1024K, 77% used [0x0000000740e00000,0x0000000740ec6030,0x0000000740f00000)
* to space 1024K, 0% used [0x0000000740f00000,0x0000000740f00000,0x0000000741000000)
* ParOldGen total 10240K, used 8K [0x00000006c0c00000, 0x00000006c1600000, 0x0000000740600000)
* object space 10240K, 0% used [0x00000006c0c00000,0x00000006c0c02000,0x00000006c1600000)
* Metaspace used 3399K, capacity 4496K, committed 4864K, reserved 1056768K
* class space used 370K, capacity 388K, committed 512K, reserved 1048576K*/}