Saturday, 30 September 2023

Difference Between PermGen (Permanent Generation) and Metaspace in Java

        In this post, we will discuss the differences between PermGen (Permanent Generation) and Metaspace in Java.

Before Java 8, class metadata was stored in the PermGen (Permanent Generation) memory space. If the allocated PermGen space was exhausted, the JVM threw an OutOfMemoryError. By default, the PermGen size was limited, and if required, it could be increased using JVM options such as -XX:MaxPermSize.

Java 8 removed PermGen and introduced Metaspace to address these limitations. Unlike PermGen, Metaspace stores class metadata in native memory rather than in the JVM heap. By default, Metaspace automatically expands as needed (subject to the available native memory), eliminating the need to manually increase its size in most cases. If required, its maximum size can still be limited using the -XX:MaxMetaspaceSize JVM option.

PermGen and Metaspace difference

Thank you for visiting the blog.

No comments:

Post a Comment