8

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?

fglez
  • 7,964
  • 4
  • 43
  • 75
Nav
  • 9,588
  • 17
  • 52
  • 80
  • 1
    It would help your question to have links to the comments you reference, so we can read them too. – Paul Bellora Dec 06 '11 at 21:52
  • Don't follow what you're actually asking? Does the JVM actually co-locate in its memory space the data that is considered permanent with collectible spaces? Probably only the guy who actually wrote it can tell you that. Conceptually it can be considered 'heap' since things are dynamically allocated *into* it at runtime, they just never leave. Configuration wise, it is a separate amount of memory allocated in addition to the 'heap.' – Affe Dec 06 '11 at 22:24
  • I had the same question and landed to this link, after reading all answers, I can say question still remains open.. – Jayesh May 13 '16 at 05:11

5 Answers5

4

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.

Community
  • 1
  • 1
GreenMatt
  • 16,928
  • 6
  • 49
  • 75
  • See this link..here it says it is different ..whom to believe :( http://blogs.oracle.com/jonthecollector/entry/presenting_the_permanent_generation – Nav Dec 06 '11 at 21:59
  • I am totally confused :'( regarding this – Nav Dec 06 '11 at 22:00
  • Well, what's the difference for *you*, then? Why not settle on this point of view -- that perm gen is counted separately from "heap". What are consequences for you if outcome this or opposite? – Victor Sorokin Dec 06 '11 at 22:02
  • @Nav: Updated answer. Also, I echo Victor Sorokin's comment a bit: Is this really that important to something you're working on? If so, how? Knowing so may help someone help you. (Although I doubt that I can help any more). Good luck! – GreenMatt Dec 06 '11 at 22:37
  • I just wanted to know ... I saw too many answers so got confused so thought will ask the experts ;) – Nav Dec 06 '11 at 22:51
  • Thanks for taking the time Matt :) – Nav Dec 06 '11 at 23:02
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.

fglez
  • 7,964
  • 4
  • 43
  • 75
1

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

Community
  • 1
  • 1
Jiacai Liu
  • 2,260
  • 2
  • 16
  • 32
1

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.

Ian Durkan
  • 1,162
  • 1
  • 11
  • 26
0

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

Jerin Joseph
  • 497
  • 5
  • 16