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

StackOverflow https://stackoverflow.com/questions/8407318

  •  29-10-2019
  •  | 
  •  

Pergunta

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?

Foi útil?

Solução

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.

Outras dicas

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.

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.

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

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

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top