Javatpoint Logo
Javatpoint Logo

PermGen space Java

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. All the static content is stored by the JVM to this memory section. Static content can be a static method, references to the static object and primitive variables. PermGen also contains information about bytecode, names, and JIT. Before releasing Java 7, String Pool is also available in this space and separate from it after releasing Java 7.

The JVM memory is divided into two parts, which are as follows:

  1. PermGen Space (Permanent Generation)
  2. Heap Space
    1. Eden Space(Young Generation)
    2. Survivor Space(Young Generation)
    3. Old Generation
PermGen space Java

The PermGen space contains the internal representation of the Java classes that JVM holds. The Permanent Generation is the garbage data that is collected in the same way as heap's other parts collected. It is a special area of memory that contains meta-data of the program's classes and the program's objects. It also contains the class-loaders that are manually destroyed at the end of the use. Here, the Garbage Collector is not that efficient and due to which it causes the Out of Memory: PermGen space error quite a few times.

The main disadvantage of the PermGen space is that it's maximum size is fixed. The 64 MB and the 82 MB are the maximum memory size for 32-bit and 64-bit version of JVM, respectively. We can modify its default size with the help of the following options:

  • XX: PermSize
    The XX: PermSize is the minimum or initial size of the PermGen space.
  • XX: MaxPermSize
    The XX: MaxPermSize is the maximum size.

Let's take an example to generate the PermGen space error and analyze it.

TestMemory.java

Now, run the above code as a configuration. We will add the following command to the argument:

The argument value will redirect verbose garbage collection output to a file gc.log.

PermGen space Java

After clicking on the Run, we get the following output.

Output:

PermGen space Java





Youtube For Videos Join Our Youtube Channel: Join Now

Feedback


Help Others, Please Share

facebook twitter pinterest

Learn Latest Tutorials


Preparation


Trending Technologies


B.Tech / MCA