Introduction

We will discuss here why PermGen space was removed from Java 8.

What is PermGen Space?

The PermGen or permanent generation space is special space because it holds meta-data describing user classes, i.e., classes that are not part of the Java language.

Examples of such meta-data are objects describing classes and methods, such as, fully qualified name of the class, fully qualified name of the immediate parent class, variable information, constructor information, constant pool, static fields, etc. and they are stored in the PermGen space.

Applications with large code-base can quickly fill up this segment of the heap which will cause java.lang.OutOfMemoryError: PermGen, no matter how high your -Xmx and how much memory you have on the machine.

Static methods and variables were Stored in the PermGen space prior to Java version 8. But now in Java 8, a new memory space was introduced, called MetaSpace, where all fields of the class, methods of a class with the byte code of the methods, constant pool, JIT optimizations, etc are stored.

Reason for removing PermGen

The main reason for removing PermGen in Java 8 is:

  • It is very hard to predict the required size of PermGen
  • It helps in improving Garbage Collection Performance by reclaiming the JVM memory

Thanks for reading.

Tags:

Leave a Reply

Your email address will not be published. Required fields are marked *