fundamentals
What is MetaSpace? How does it differ from PermGen?
MetaSpace (Java 8+) replaced the PermGen (Permanent Generation) from earlier versions.
Key Differences:
- Memory Type: PermGen was part of the JVM Heap (contiguous memory). MetaSpace uses Native Memory (RAM outside the heap).
- Sizing: PermGen had a fixed max size (
-XX:MaxPermSize), often leading tojava.lang.OutOfMemoryError: PermGen space. MetaSpace can grow dynamically based on available system memory. - Management: Garbage collection of classes is more efficient in MetaSpace.
- Args: PermGen used
-XX:PermSize; MetaSpace uses-XX:MetaspaceSize.