在Java 8中使用MetaSpace有什么用? [英] What is the use of MetaSpace in Java 8?

查看:253
本文介绍了在Java 8中使用MetaSpace有什么用?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道他们已经用Java 8中的MetaSpace取代了PermGen。但我有几个问题:


  1. 默认情况下MetaSpace是GC收集?

  2. 甚至PermGen通过添加诸如 -XX:+ CMSClassUnloadingEnabled 之类的参数来收集GC,那么是什么使MetaSpace比PermGen更好? / li>
  3. MetaSpace基于本机内存,因此它将Java对象保留在磁盘而不是VM上?

  4. 即使MetaSpace可能会耗尽内存?如果是这样,我会得到 OutOfMemoryException

  5. 默认情况下,MetaSpace可以增加内存?

预先致谢

解决方案


默认情况下,MetaSpace是否收集了GC?


是的,GC会在元数据空间运行,它也会动态增加
(允许它)分配给
元数据的内存。


PermGen是通过添加如-XX:+ CMSClassUnloadingEnabled之类的参数来收集GC的,那么是什么让MetaSpace比PermGen更好?


改进之处在于元空间的动态扩展是
是permgen所无法做到的。


MetaSpace基于本机内存,所以它将java对象保留在磁盘而不是VM上?


基于对metaspace的描述,它只使用本机内存
(无分页)。



基于Pierre - Hugu es Charbonneau(此处链接)清楚地表明,元代空间的引入并没有它必须解决OOM问题,它最多只能解决问题,它会尝试动态调整元数据空间内存的大小,以适应不断增长的不受控制地增长的副作用的类的数量的增加(只要本地内存允许它可以通过设置 MaxMetaspaceSize 参数给JVM并运行示例程序来实现着名的OOM错误。

提供。



非常感谢Pierre - Hugues Charbonneau。


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

  1. Is MetaSpace by default is GC collected?
  2. Even the PermGen is GC collected by adding the args like -XX:+CMSClassUnloadingEnabled, then what makes MetaSpace better than PermGen?
  3. MetaSpace is based on native memory, so it keeps the java objects on the disks rather than on VM?
  4. Even MetaSpace can run out of memory? If so again I will get OutOfMemoryException.
  5. 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.

这篇关于在Java 8中使用MetaSpace有什么用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆