PermGen and Heap, Difference and their significance
Solution 1
Memory(Heap) is managed in generations, or memory pools holding objects of different ages. Garbage collection occurs in each generation when the generation fills up. Objects are allocated in a generation for younger objects or the young generation
, and because of infant mortality most objects die there.
When any new object is constructed it goes to Eden space which is a part of Young Generation
.
If object is still alive after some time it goes to tenured generation
where long lived objects lie.
If object is supposed to live until over process exist then object is moved to Perm Generation
.Java classes
are stored in the permanent generation.
Solution 2
Good links are there in What does PermGen actually stand for?. Especially liked this blog
Solution 3
I was having the same doubt about the PermGen and other Heap memory parts. After doing some search, here what I finally concluded.
Java HotSpot VM needs memory which it gets from the operating system, this memory is termed as Heap memory. Now heap memory as famously known to store the objects and holds other important things as well.
Short live span Java objects are stored in the young generation and if those objects are still needed for further execution then, it is shifted to the tenure/old generation. And depending upon the type of Generation Garbage Collector, memory is cleaned.
What about the Permanent Generation (PermGen)? Java HotSpot VM loads the classes/class structure in the PermGen which is used by JVM to store loaded classes and other meta-data. PermGen is not used to store objects.
Apart from objects and class structure, JVM code itself loads profiler agent code and data etc.
So basically, heap = object + class structure + JVM architecture.
References: Java Docs, Java GC Guide
Comments
-
Punith Raj almost 2 years
Friends,
Can you please give me significance, difference and uses for Heap and PermGen. Also it would be good to know what class are loaded in them respectively.
Explanation related to Java VM specification would be really helpful
Thanks Punith
-
Ravindra babu over 7 yearsRefer to this related question: stackoverflow.com/questions/2070791/…
-
-
Santosh almost 12 yearsThats not true. PerGen is a separate from heap space. check (this)[blogs.oracle.com/jonthecollector/entry/…
-
Ed Morales almost 12 yearsyeah, you are correct. I'm not sure were i read otherwise but it does make sense since what they meant to achieve with separating it is for the GC to not check for permanent data, so it just checks the heap for "things" that he can collect.