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

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

问题描述

我知道他们在 Java 8 中已将 PermGen 替换为 MetaSpace.但我有几个问题:

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

  1. MetaSpace默认是GC收集的吗?
  2. 连PermGen都是GC收集的,加了-XX:+CMSClassUnloadingEnabled之类的args,那MetaSpace有什么比PermGen更好的地方呢?
  3. MetaSpace 是基于本地内存的,所以它会将 java 对象保存在磁盘上而不是 VM 上?
  4. 即使 MetaSpace 也会耗尽内存?如果再次这样,我会得到 OutOfMemoryException.
  5. 默认情况下,MetaSpace 可以随着内存的增加而增长?
  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?

提前致谢

推荐答案

MetaSpace默认是GC收集的吗?

Is MetaSpace by default is GC collected?

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

Yes, GC will run on metaspace when its getting full, it would also dynamically increase (given its allowed to) the memory allocated for metadata.

连PermGen都加了​​-XX:+CMSClassUnloadingEnabled这样的args被GC收集了,那MetaSpace有什么比PermGen更好的地方呢?

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

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

The improvement is with the dynamic expansion of the metaspace which is something permgen wasn't able to do.

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

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).

基于 Pierre - Hugues Charbonneau 的研究(链接在这里),很明显,元空间的引入并不一定能解决 OOM 问题,它充其量只是解决问题的方法,它试图动态调整元空间内存的大小以适应越来越多的类加载可能的副作用不受控制的增长(只要本机内存允许).

Based on the research by Pierre - Hugues Charbonneau (link here), it's clear that the introduction of metaspace doesn't necessarily solve the OOM issue, it's 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).

我们可以通过将 MaxMetaspaceSize 参数设置为 JVM 并运行提供的示例程序来实现著名的 OOM 错误.

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

非常感谢 Pierre - Hugues Charbonneau.

many thanks to Pierre - Hugues Charbonneau.

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

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