Java 8 : Metaspace

With Java 8, Permanent Generation(PermGen) has been removed and is replaced with Metaspace.

Permanent Generation(PermGen): It is considered as part of Method Area(Non-Heap Area) in JVM.

  • This area stores class related data from class definitions, structures, methods, field, method (data and code) and constants. Can be regulated using -XX:PermSize and -XX:MaxPermSize. It can cause java.lang.OutOfMemoryError when it runs out if space.
  • With the removal of PermGen memory space in Java 8, we will no longer get java.lang.OutOfMemoryError: PermGen space problems and no need to tune and monitor this memory space anymore.


Metaspace is a new memory space which  has replaced PermGen.

  • By default class metadata allocation is limited by the amount of available native memory. The max available space is the total available system memory.
  • A new flag is available (MaxMetaspaceSize), allowing you to limit the amount of native memory used for class metadata. If you don’t specify this flag, the Metaspace will dynamically re-size depending of the application demand at runtime.
    Metaspace garbage collection
  • Garbage collection of the dead classes and classloaders is triggered once the class metadata usage reaches the MaxMetaspaceSize.

Leave a Reply

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