byte[] allocation1, allocation2, allocation3, allocation4; allocation1 = newbyte[2 * _1MB]; allocation2 = newbyte[2 * _1MB]; allocation3 = newbyte[2 * _1MB]; allocation4 = newbyte[4 * _1MB]; // 出现一次Minor GC } } /* [GC [DefNew: 6825K->172K(9216K), 0.0045184 secs] 6825K->6316K(19456K), 0.0045424 secs] [Times: user=0.00 sys=0.00, real=0.00 secs] Heap def new generation total 9216K, used 4598K [0x33050000, 0x33a50000, 0x33a50000) eden space 8192K, 54% used [0x33050000, 0x334a27a0, 0x33850000) from space 1024K, 16% used [0x33950000, 0x3397b060, 0x33a50000) to space 1024K, 0% used [0x33850000, 0x33850000, 0x33950000) tenured generation total 10240K, used 6144K [0x33a50000, 0x34450000, 0x34450000) the space 10240K, 60% used [0x33a50000, 0x34050030, 0x34050200, 0x34450000) compacting perm gen total 12288K, used 424K [0x34450000, 0x35050000, 0x38450000) the space 12288K, 3% used [0x34450000, 0x344ba2f8, 0x344ba400, 0x35050000) ro space 10240K, 55% used [0x38450000, 0x389d3320, 0x389d3400, 0x38e50000) rw space 12288K, 55% used [0x38e50000, 0x394f6128, 0x394f6200, 0x39a50000)
/* Heap def new generation total 9216K, used 845K [0x33050000, 0x33a50000, 0x33a50000) eden space 8192K, 10% used [0x33050000, 0x331234d0, 0x33850000) from space 1024K, 0% used [0x33850000, 0x33850000, 0x33950000) to space 1024K, 0% used [0x33950000, 0x33950000, 0x33a50000) tenured generation total 10240K, used 4096K [0x33a50000, 0x34450000, 0x34450000) the space 10240K, 40% used [0x33a50000, 0x33e50010, 0x33e50200, 0x34450000) compacting perm gen total 12288K, used 424K [0x34450000, 0x35050000, 0x38450000) the space 12288K, 3% used [0x34450000, 0x344ba260, 0x344ba400, 0x35050000) ro space 10240K, 55% used [0x38450000, 0x389d3320, 0x389d3400, 0x38e50000) rw space 12288K, 55% used [0x38e50000, 0x394f6128, 0x394f6200, 0x39a50000)
可以从 total 10240K, used 4096K ,这一条得出,大对象直接进入到了老年代,不过不是默认进行的,需要使用:-XX:+PrintTenuringDistribution。进行设置。
[GC [DefNew Desired survivor size 524288 bytes, new threshold 1 (max 1) - age 1: 438384 bytes, 438384 total : 5033K->428K(9216K), 0.0044237 secs] 5033K->4524K(19456K), 0.0044527 secs] [Times: user=0.00 sys=0.00, real=0.00 secs] [GC [DefNew Desired survivor size 524288 bytes, new threshold 1 (max 1) - age 1: 224 bytes, 224 total : 4772K->0K(9216K), 0.0009550 secs] 8868K->4524K(19456K), 0.0009794 secs] [Times: user=0.00 sys=0.00, real=0.00 secs] Heap def new generation total 9216K, used 4234K [0x33050000, 0x33a50000, 0x33a50000) eden space 8192K, 51% used [0x33050000, 0x334728b0, 0x33850000) from space 1024K, 0% used [0x33850000, 0x338500e0, 0x33950000) to space 1024K, 0% used [0x33950000, 0x33950000, 0x33a50000) tenured generation total 10240K, used 4523K [0x33a50000, 0x34450000, 0x34450000) the space 10240K, 44% used [0x33a50000, 0x33ebafb0, 0x33ebb000, 0x34450000) compacting perm gen total 12288K, used 428K [0x34450000, 0x35050000, 0x38450000) the space 12288K, 3% used [0x34450000, 0x344bb298, 0x344bb400, 0x35050000) ro space 10240K, 55% used [0x38450000, 0x389d3320, 0x389d3400, 0x38e50000) rw space 12288K, 55% used [0x38e50000, 0x394f6128, 0x394f6200, 0x39a50000)
[GC [DefNew Desired survivor size 524288 bytes, new threshold 15 (max 15) - age 1: 438384 bytes, 438384 total : 5033K->428K(9216K), 0.0040562 secs] 5033K->4524K(19456K), 0.0040857 secs] [Times: user=0.00 sys=0.00, real=0.00 secs] [GC [DefNew Desired survivor size 524288 bytes, new threshold 15 (max 15) - age 1: 224 bytes, 224 total - age 2: 438176 bytes, 438400 total : 4772K->428K(9216K), 0.0008210 secs] 8868K->4524K(19456K), 0.0008423 secs] [Times: user=0.00 sys=0.00, real=0.00 secs] Heap def new generation total 9216K, used 4662K [0x33050000, 0x33a50000, 0x33a50000) eden space 8192K, 51% used [0x33050000, 0x334728b0, 0x33850000) from space 1024K, 41% used [0x33850000, 0x338bb080, 0x33950000) to space 1024K, 0% used [0x33950000, 0x33950000, 0x33a50000) tenured generation total 10240K, used 4096K [0x33a50000, 0x34450000, 0x34450000) the space 10240K, 40% used [0x33a50000, 0x33e50010, 0x33e50200, 0x34450000) compacting perm gen total 12288K, used 426K [0x34450000, 0x35050000, 0x38450000) the space 12288K, 3% used [0x34450000, 0x344bb108, 0x344bb200, 0x35050000) ro space 10240K, 55% used [0x38450000, 0x389d3320, 0x389d3400, 0x38e50000) rw space 12288K, 55% used [0x38e50000, 0x394f6128, 0x394f6200, 0x39a50000)
/* [GC [DefNew Desired survivor size 524288 bytes, new threshold 1 (max 15) - age 1: 700544 bytes, 700544 total : 5289K->684K(9216K), 0.0044213 secs] 5289K->4780K(19456K), 0.0044653 secs] [Times: user=0.02 sys=0.02, real=0.00 secs] [GC [DefNew Desired survivor size 524288 bytes, new threshold 15 (max 15) - age 1: 224 bytes, 224 total : 5028K->0K(9216K), 0.0013033 secs] 9124K->4780K(19456K), 0.0013299 secs] [Times: user=0.00 sys=0.00, real=0.00 secs] Heap def new generation total 9216K, used 4234K [0x33050000, 0x33a50000, 0x33a50000) eden space 8192K, 51% used [0x33050000, 0x33472858, 0x33850000) from space 1024K, 0% used [0x33850000, 0x338500e0, 0x33950000) to space 1024K, 0% used [0x33950000, 0x33950000, 0x33a50000) tenured generation total 10240K, used 4779K [0x33a50000, 0x34450000, 0x34450000) the space 10240K, 46% used [0x33a50000, 0x33efafc0, 0x33efb000, 0x34450000) compacting perm gen total 12288K, used 428K [0x34450000, 0x35050000, 0x38450000) the space 12288K, 3% used [0x34450000, 0x344bb2c8, 0x344bb400, 0x35050000) ro space 10240K, 55% used [0x38450000, 0x389d3320, 0x389d3400, 0x38e50000) rw space 12288K, 55% used [0x38e50000, 0x394f6128, 0x394f6200, 0x39a50000)