Short answer
Metaspace stores class metadata — class structures, method bytecode, constant pool.
Explanation
PermGen (the permanent generation) served this role until it was removed in Java 8 and replaced by Metaspace. The key difference: PermGen lived inside the heap with a fixed max size (-XX:MaxPermSize), so class-heavy apps hit OutOfMemoryError: PermGen space; Metaspace lives in native (off-heap) memory and grows dynamically by default. You can still cap it with -XX:MaxMetaspaceSize, and leaks (e.g. classloader leaks) surface as OutOfMemoryError: Metaspace.
Common mistakes
- Saying Metaspace cannot run out.
- Not knowing class-loader leaks fill it.