永久代是堆的一部分还是位于 jvm 中的不同空间中

发布于 2024-12-20 00:47:09 字数 121 浏览 1 评论 0原文

我看到很多关于这个问题的评论 - 有人说是,有人说不是,而且许多答案都是模棱两可的。任何人都可以用更简单的术语描述它所在的位置吗?在一篇文章中,我什至看到有人说它与类内存共享相同的内存位置,其中类由类加载器加载 - 这是真的吗?

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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(5

梦途 2024-12-27 00:47:10

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

似梦非梦 2024-12-27 00:47:09

原始(可能是错误的)答案:如果维基百科可信,那么它是堆。

编辑:我已经对此进行了更多研究,包括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.

勿挽旧人 2024-12-27 00:47:09

从黑盒角度来看,在 Sun JVM 中,永久代不是堆的一部分,如 jconsole 的文档

永久代(非堆):包含所有内存的池
虚拟机本身的反射数据,例如类和
方法对象。对于使用类数据共享的 Java VM,这
Generation分为只读区和读写区。

实际上,这意味着您的 -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:

Permanent Generation (non-heap): The pool containing all the
reflective data of the virtual machine itself, such as class and
method objects. With Java VMs that use class data sharing, this
generation is divided into read-only and read-write areas.

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.

逆光下的微笑 2024-12-27 00:47:09

以下是我对该主题的理解:

永久代存储类定义的堆区域。如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.

夜清冷一曲。 2024-12-27 00:47:09

我在阅读Java垃圾收集基础知识<时遇到了同样的问题/a>,在本教程中,作者认为永久代是堆的一部分。

但我们都有:

  • -Xmx
  • -XX:MaxPermSize

,在谷歌搜索问题后,我发现这个问题 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:

  • -Xmx
  • -XX:MaxPermSize

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文