JAVA8 Metaspace内容,在Java 8中使用MetaSpace有什么用?

I know they have replaced PermGen with MetaSpace in Java 8. But I have few questions:

Is MetaSpace by default is GC collected?

Even the PermGen is GC collected by adding the args like -XX:+CMSClassUnloadingEnabled, then what makes MetaSpace better than PermGen?

MetaSpace is based on native memory, so it keeps the java objects on the disks rather than on VM?

Even MetaSpace can run out of memory? If so again I will get OutOfMemoryException.

By default the MetaSpace can grow on increase in memory?

Thanks in advance

解决方案

Is MetaSpace by default is GC collected?

Yes, GC will run on metaspace when its getting full, it would also

dynamically increase (given its allowed to) the memory allocated for

metadata.

Even the PermGen is GC collected by adding the args like -XX:+CMSClassUnloadingEnabled, then what makes MetaSpace better than PermGen?

The improvement is with the dynamic expansion of the metaspace which

is something permgen wasn't able to do.

MetaSpace is based on native memory, so it keeps the java objects on the disks rather than on VM?

Based on the description of metaspace, it only uses the native memory

(no paging).

Based on the research by Pierre - Hugues Charbonneau (link here) its clear that the introduction of metaspace doesn't necessarily solve the OOM issue, its a bandaid to the problem at best, it attempts to dynamically resize the metaspace memory to accomodate the growing number of classes which get loaded with a possible side effect of growing uncontrollably (so long as the native memory permits it).

We can achieve the famed OOM error by setting the MaxMetaspaceSize argument to JVM and running the sample program provided.

many thanks to Pierre - Hugues Charbonneau.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值