Java JDK 8 中的 PermGen 消除
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/18339707/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
PermGen elimination in JDK 8
提问by Shamim Ahmmed
I have installed JDK 8 and trying to run Eclipse. I am getting following warning message:
我已经安装了 JDK 8 并尝试运行 Eclipse。我收到以下警告消息:
Java HotSpot(TM) 64-Bit Server VM warning: ignoring option MaxPermSize=512m;
support was removed in 8.0
What are the reasons for ignoring this VM option?
忽略此 VM 选项的原因是什么?
采纳答案by pardeep131085
Reasons of ignoring these argument is permanent generation has been removed in HotSpot for JDK8 because of following drawbacks
忽略这些参数的原因是由于以下缺点,在 HotSpot for JDK8 中删除了永久生成
- Fixed size at startup – difficult to tune.
- Internal Hotspot types were Java objects : Could move with full GC, opaque, not strongly typed and hard to debug, needed meta-metadata.
- Simplify full collections : Special iterators for metadata for each collector
- Want to deallocate class data concurrently and not during GC pause
- Enable future improvements that were limited by PermGen.
- 启动时固定大小 - 难以调整。
- 内部热点类型是 Java 对象:可以随完整 GC 移动,不透明,非强类型且难以调试,需要元元数据。
- 简化完整集合:每个收集器的元数据的特殊迭代器
- 想要同时释放类数据而不是在 GC 暂停期间
- 启用受 PermGen 限制的未来改进。
The Permanent Generation (PermGen) space has completely been removed and is kind of replaced by a new space called Metaspace. The consequences of the PermGen removal is that obviously the PermSize and MaxPermSize JVM arguments are ignoredand you will never get a java.lang.OutOfMemoryError: PermGen error.
永久代 (PermGen) 空间已被完全删除,取而代之的是一个名为 Metaspace 的新空间。删除 PermGen 的后果是很明显PermSize 和 MaxPermSize JVM 参数被忽略,你永远不会得到 java.lang.OutOfMemoryError: PermGen 错误。
Advantages of MetaSpace
元空间的优势
- Take advantage of Java Language Specification property : Classes and associated metadata lifetimes match class loader's
- Per loader storage area – Metaspace
- Linear allocation only
- No individual reclamation (except for RedefineClasses and class loading failure)
- No GC scan or compaction
- No relocation for metaspace objects
- 利用 Java 语言规范属性:类和关联的元数据生命周期与类加载器的相匹配
- 每个装载机存储区域 – Metaspace
- 仅线性分配
- 没有单独的回收(除了 RedefineClasses 和类加载失败)
- 没有 GC 扫描或压缩
- 元空间对象没有重定位
Metaspace Tuning
元空间调整
The maximum metaspace size can be set using the -XX:MaxMetaspaceSize flag, and the default is unlimited, which means that only your system memory is the limit. The -XX:MetaspaceSize tuning flag defines the initial size of metaspace If you don't specify this flag, the Metaspace will dynamically re-size depending of the application demand at runtime.
可以使用 -XX:MaxMetaspaceSize 标志设置最大元空间大小,默认为无限制,这意味着只有您的系统内存是限制。-XX:MetaspaceSize 调整标志定义元空间的初始大小。如果不指定此标志,元空间将在运行时根据应用程序需求动态重新调整大小。
Change enables other optimizations and features in the future
更改可以在未来实现其他优化和功能
- Application class data sharing
- Young collection optimizations, G1 class unloading
- Metadata size reductions and internal JVM footprint projects
- 应用类数据共享
- Young 集合优化,G1 类卸载
- 元数据大小减少和内部 JVM 占用空间项目
There is improved GC performace also. More detail
GC 性能也有所提高。更多详情
回答by chrylis -cautiouslyoptimistic-
回答by Sebastian Redl
Because the PermGen space was removed. Memory management has changed a bit.
因为永久代空间被移除了。内存管理发生了一些变化。
回答by assylias
This is one of the new features of Java 8, part of JDK Enhancement Proposals 122:
这是 Java 8 的新特性之一,是JDK Enhancement Proposals 122 的一部分:
Remove the permanent generation from the Hotspot JVM and thus the need to tune the size of the permanent generation.
从 Hotspot JVM 中删除永久代,因此需要调整永久代的大小。
The list of all the JEPs that will be included in Java 8 can be found on the JDK8 milestones page.
可以在JDK8 里程碑页面上找到将包含在 Java 8 中的所有JEP 的列表。
回答by Dhrumil Shah
The Permanent Generation (PermGen) space has completely been removed and is kind of replaced by a new space called Metaspace.The consequences of the PermGen removal is that obviously the PermSize and MaxPermSize JVM arguments are ignored and you will never get a java.lang.OutOfMemoryError
: PermGen error.
The JDK 8 HotSpot JVM is now using native memory for the representation of class metadata and is called Metaspace.Read More>>
永久代 (PermGen) 空间已完全删除,并被称为 Metaspace 的新空间所取代。删除 PermGen 的后果显然是 PermSize 和 MaxPermSize JVM 参数被忽略,您将永远不会收到java.lang.OutOfMemoryError
: PermGen 错误。
JDK 8 HotSpot JVM 现在使用本机内存来表示类元数据,称为 Metaspace。阅读更多>>
回答by Shubham Pandey
PermGen space is replaced by MetaSpace in Java 8. The PermSize and MaxPermSize JVM arguments are ignored and a warning is issued if present at start-up.
PermGen 空间在 Java 8 中被 MetaSpace 取代。 PermSize 和 MaxPermSize JVM 参数被忽略,如果在启动时存在,则会发出警告。
Most allocations for the class metadata are now allocated out of native memory. * The classes that were used to describe class metadata have been removed.
类元数据的大部分分配现在都分配在本机内存之外。* 用于描述类元数据的类已被删除。
Main difference between old PermGen and new MetaSpace is, you don't have to mandatory define upper limit of memory usage. You can keep MetaSpace space limit unbounded. Thus when memory usage increases you will not get OutOfMemoryError error. Instead the reserved native memory is increased to full-fill the increase memory usage.
旧的 PermGen 和新的 MetaSpace 的主要区别在于,您不必强制定义内存使用上限。您可以让 MetaSpace 空间限制不受限制。因此,当内存使用量增加时,您不会收到 OutOfMemoryError 错误。而是增加保留的本机内存以填满增加的内存使用量。
You can define the max limit of space for MetaSpace, and then it will throw OutOfMemoryError : Metadata space. Thus it is important to define this limit cautiously, so that we can avoid memory waste.
您可以为 MetaSpace 定义最大空间限制,然后它会抛出 OutOfMemoryError : Metadata space。因此,谨慎地定义此限制很重要,这样我们就可以避免内存浪费。