Is permanent generation part of the heap or does it lies in a different space of itself in jvm

五迷三道 提交于 2019-11-30 15:14:00

问题


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?


回答1:


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.




回答2:


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.




回答3:


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.




回答4:


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




回答5:


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



来源:https://stackoverflow.com/questions/8407318/is-permanent-generation-part-of-the-heap-or-does-it-lies-in-a-different-space-of

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!