Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Permgen is part of heap or not?

I have found picture from official oracle siteenter image description here

but in popular SO answer I have found that permanent generation is not part of heap

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.

I messed with these contradictory datas. I believe that at both places data valid but with reservations. Please clarify this question for me.

P.S.

let speak only about Sun/Oracle jvms.

P.S.2

I have read explanation of jvm gcs(serial,parallel, cms and g1) and I didn't see mentions about permgen it argument to side that permanent generation is not heap part.

like image 829
gstackoverflow Avatar asked Dec 28 '16 09:12

gstackoverflow


Video Answer


1 Answers

I believe you are referring the diagram from here, about Oracle's official site, and yes they are quoting "permanent generation" as heap area but I guess intent was just trying to explain the "generations" in JVM memory; but as per best of my knowledge (and I guess many experts will agree with it) "permanent generation" is not part of heap area, it is part of non-heap area which is used by JVM to internal purpose like JIT optimization, method areas etc.

Oracle official references

I would like to quote below 3 official Oracle references to help you get convinced that "permanent generation" is not part of heap area.

  1. jConsole guide from Oracle.
  2. Blog of a Oracle GC developer.
  3. Oracle article on GC tuning

In the first link above, you can clearly see that it is explained that Java manages 2 kind of memory - Heap and Non-Heap Memory, and then they have listed "generations" present in each type of memory. You can read this section in the link "Monitoring Memory Consumption", and below is some excerpt.

enter image description here enter image description here

Then in the second link from above, GC developer has very well explained the purpose and insight of "permanent generation", using which it can be clearly understood that "permanent generation" is not a heap area, see below diagram from the blog:

enter image description here

Then in the third link from above, you can refer the memory measurements done in section 3.2 "Measurement", which also makes it clear that "permanent generation" is not part of heap area.

Also, you would know that after a full GC in "Tenured generation", in worst case JVM would throw out of memory exception but would not promoted the objects to "permanent generation" because it is not part of heap area.

Non-Oracle references

Checkout below diagram, and many such diagrams can be found which explains the memory tuning arguments of JVM. If you see from memory tuning JVM arguments perspective as well then also it is self-evident that "permanent generation" is not part of heap area.

enter image description here

In the end

Now, I think it should be clear to you that the diagram (and its article) was just meant to explain the JVM memory concept from "generations" perspective, but in implementation JVM doesn't consider "permanent generation" to be part of heap memory where it can promote the long-lived objects.

like image 175
hagrawal Avatar answered Nov 03 '22 17:11

hagrawal