永久代是堆的一部分还是位于 jvm 中的不同空间中
我看到很多关于这个问题的评论 - 有人说是,有人说不是,而且许多答案都是模棱两可的。任何人都可以用更简单的术语描述它所在的位置吗?在一篇文章中,我什至看到有人说它与类内存共享相同的内存位置,其中类由类加载器加载 - 这是真的吗?
I have seen multiple comments regarding this question - some say yes and some say no, and many of the answers are ambiguous. Can anyone please describe in simpler terms where it resides? In one post I even saw someone say that it shares the same memory place as class memory where classes are loaded into by classloaders - is that true?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
Permgen 已从 Java 8 中删除。现在我们有了元空间,它不属于堆,也不属于内部存储器。
还有命令
-Xmx
-XX:最大PermSize
中将被忽略
从 Java 8 http://java.dzone.com/articles/ java-8-permgen-元空间
Permgen is removed from Java 8. Now we have metaspace which is not part of heap and part of internal memory.
Also the commands
-Xmx
-XX:MaxPermSize
will be ignored from Java 8
http://java.dzone.com/articles/java-8-permgen-metaspace
原始(可能是错误的)答案:如果维基百科可信,那么它是堆。
编辑:我已经对此进行了更多研究,包括OP评论中引用的网站。在这项研究中,我遇到了这个SO问题,它引用了本文档,这表明对于Sun Java(版本6),永久集合实际上位于堆之外。也就是说,我不是 Java 专家,之前也不知道这个级别的内存管理细节。如果我的理解是正确的,那么永久代的放置(甚至存在)就是 jvm 实现细节。
Original (perhaps mistaken) answer: If wikipedia is to be believed, it's part of the heap.
Edit: I've looked around at this more, including the site referenced in a comment by the OP. During this research I came across this SO question, which references this document, which indicates that for Sun Java (version 6), the permanent collection is actually outside the heap. That said, I'm no Java expert and wasn't previously aware of the memory management details at this level. If my reading is correct, the placement - or even the existence - of the permanent generation is a jvm implementation detail.
从黑盒角度来看,在 Sun JVM 中,永久代不是堆的一部分,如
jconsole
的文档:实际上,这意味着您的
-XX:MaxPermSize
内存会添加到 JVM 进程中的-Xmx
内存,因为永久代不包含在堆中。From a blackbox perspective, in Sun JVMs, Permanent Generation is not part of the heap as stated in
jconsole
's documentation:In practice, this means that your
-XX:MaxPermSize
memory adds up to your-Xmx
memory in the JVM process, as permanent generation is not included in the heap.以下是我对该主题的理解:
永久代是存储类定义的堆区域。如http://blogs.oracle.com/jonthecollector/entry/presenting_the_permanent_ Generation所示,所有类实例都有一个“klass”引用,指向永久代中其类型的类的实例。当在运行时创建新类型时,会在永久代中为其类型分配新空间。
Jon Masamitsu 博客文章中的图表显示了永久代与堆中可存储程序对象实例的更频繁收集部分之间的逻辑分离。永久代仍然是堆的一部分。
Here is my understanding of the topic:
The permanent generation is the region of the heap where class definitions are stored. As shown at http://blogs.oracle.com/jonthecollector/entry/presenting_the_permanent_generation, all class instances have a 'klass' reference to an instance of their type's class in the permanent generation. When new types are created at runtime, new space is allocated in the permanent generation for their types.
The diagram on Jon Masamitsu's blog post shows the logical separation between the permanent generation and the more-frequently-collected parts of the heap where your program's object instances can be stored. The permanent generation is still part of the heap.
我在阅读Java垃圾收集基础知识<时遇到了同样的问题/a>,在本教程中,作者认为永久代是堆的一部分。
但我们都有:
,在谷歌搜索问题后,我发现这个问题 Java堆术语:年轻一代、老一代和永久代?,答案得出结论:
永久代不是堆的一部分
I came the same question when reading Java Garbage Collection Basics,in this turtorial,the author views permanent-generation is part of heap.
But we have both:
and after google the question,I find this questions Java heap terminology: young, old and permanent generations?,answers from which conclude:
permanent-generation is not part of heap