请帮我分析一下这个gc日志,看不懂。。

黄橙蓝 2018-04-05 04:11:14
public static void main(String[] args) {
byte[] a1,a2,a3;
a1 = new byte[4 * _1M];
a2 = new byte[4 * _1M];
System.out.println("1");
a3 = new byte[4 * _1M];
System.out.println("2");
a3 = null;
System.out.println("3");
a3 = new byte[4 * _1M];
System.out.println("4");
}


JVM配置:-verbose:gc -Xms20m -Xmx20m -Xmn10m -XX:+PrintGCDetails -XX:SurvivorRatio=8 -XX:+UseSerialGC
控制台输出:
[GC (Allocation Failure) [DefNew: 5079K->525K(9216K), 0.0024421 secs] 5079K->4621K(19456K), 0.0024969 secs] [Times: user=0.00 sys=0.00, real=0.00 secs]
1
[GC (Allocation Failure) [DefNew: 4779K->0K(9216K), 0.0020170 secs] 8875K->8716K(19456K), 0.0020318 secs] [Times: user=0.00 sys=0.00, real=0.00 secs]
2
3
[GC (Allocation Failure) [DefNew: 4255K->4255K(9216K), 0.0000074 secs][Tenured: 8716K->8717K(10240K), 0.0010752 secs] 12972K->8717K(19456K),
[Metaspace: 2665K->2665K(1056768K)], 0.0011070 secs] [Times: user=0.00 sys=0.00, real=0.00 secs]
4
Heap
def new generation total 9216K, used 4418K [0x00000000fec00000, 0x00000000ff600000, 0x00000000ff600000)
eden space 8192K, 53% used [0x00000000fec00000, 0x00000000ff050b68, 0x00000000ff400000)
from space 1024K, 0% used [0x00000000ff400000, 0x00000000ff400000, 0x00000000ff500000)
to space 1024K, 0% used [0x00000000ff500000, 0x00000000ff500000, 0x00000000ff600000)
tenured generation total 10240K, used 8717K [0x00000000ff600000, 0x0000000100000000, 0x0000000100000000)
the space 10240K, 85% used [0x00000000ff600000, 0x00000000ffe83420, 0x00000000ffe83600, 0x0000000100000000)
Metaspace used 2672K, capacity 4486K, committed 4864K, reserved 1056768K
class space used 288K, capacity 386K, committed 512K, reserved 1048576K


请问:3-4中间的GC为什么DefNew和Tenured都没有变化呢?那新增的内存放哪里啦?



...全文
899 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
赵王爷 2018-08-06
  • 打赏
  • 举报
回复
你看的周志明的书吧,前两天我刚看了,手头没有电脑,没试验这些代码。你看之前一定先看他代码前的逻辑,以及之后的分析,串起来,应该没有问题的,我看将的挺细的。
weixin_41404782 2018-06-20
  • 打赏
  • 举报
回复
你无法保证垃圾收集的时机的。 打印输出语句前,sleep 几秒,看看。

25,980

社区成员

发帖
与我相关
我的任务
社区描述
高性能WEB开发
社区管理员
  • 高性能WEB开发社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧