Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Significance of PermGen Space

What is the significance of PermGen space in java?

like image 552
java_geek Avatar asked Feb 10 '10 16:02

java_geek


People also ask

What is the use of PermGen space?

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.

What is the PermGen section in 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.

What is the advantage of Metaspace?

Advantages of MetaSpace Take advantage of Java Specification property: Classes and associated metadata lifetimes match class loaders. Per loader storage area: Metaspace. Linear allocation only. No individual reclamation (except for Redefine Classes and class loading failure)


1 Answers

PermGen space is reserved for long-term objects - mostly Class objects loaded by the ClassLoader. PermGen will not be garbage collected except under very special circumstances (specifically, when the ClassLoader that loaded those classes goes out of scope).

This is a garbage collection optimization - if objects that we don't expect to be garbage collected are stored separately, it compacts the space where the rest of the objects are stored, which leads to less work for the garbage collector.

like image 161
danben Avatar answered Oct 10 '22 12:10

danben