PermGen and Heap, Difference and their significance

Punith Raj picture Punith Raj · Jun 13, 2012 · Viewed 19.9k times · Source

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

Answer

amicngh picture amicngh · Jun 13, 2012

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.