Swiftorial Logo
Home
Swift Lessons
Tutorials
Learn More
Career
Resources

Java FAQ: Top Questions

60. What is the Metaspace in Java?

Metaspace , introduced in Java 8, is a JVM memory region replacing PermGen, storing class metadata, such as class definitions and method data.

  • Native Memory: Allocated outside the Java heap, managed by the OS.
  • Dynamic Sizing: Grows or shrinks automatically, controlled by -XX:MaxMetaspaceSize .
  • Garbage Collection: Unloads unused classes during GC if space is needed.
  • Use Case: Manages memory for dynamically loaded classes.
  • OutOfMemoryError: Occurs if Metaspace is exhausted (e.g., excessive class loading).