Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PermGen and Heap, Difference and their significance

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

like image 963
Punith Raj Avatar asked Jun 13 '12 07:06

Punith Raj


People also ask

What is the difference between PermGen and heap?

PermGen stands for Permanent Generation. It is a special type of heap space. It is separate from the main memory (heap). JVM uses PermGen to keep track of loaded class metadata.

What is PermGen heap?

The PermGen area of the Java heap is used to store metadata such as class declarations, methods and object arrays. Therefore, the PermGen size requirements depend on the number of classes and methods as well as their size. Java memory is separated into different regions - Young, Tenured and PermGen.

Is PermGen part of heap memory?

PermGen (Permanent Generation) is a special heap space separated from the main memory heap. The JVM keeps track of loaded class metadata in the PermGen. Additionally, the JVM stores all the static content in this memory section.


1 Answers

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.

like image 121
amicngh Avatar answered Oct 22 '22 04:10

amicngh