JVM usage of the Metaspace
The Metaspace is a special area of native memory outside of the heap. Native memory is memory provided by the operating system to an application for its own use. The JVM uses the Metaspace to store class-related information, that is, the class’s runtime representation. This is the class’s metadata; hence the metadata is stored in the Metaspace.
Metadata
Metadata is information about data. For example, columns in a database are metadata about the data in the columns. Thus, if a column name is Name
and a specific row value is John
, then Name
is metadata about John
.
This metadata consists of the following:
- Class files
- Structure and methods of the class
- Constants
- Annotations
- Optimizations
Thus, in metadata, the JVM has everything it requires to work with the class.
PermGen
Prior to Java 8, the metadata was stored in an area (contiguous with the heap) known as PermGen, or permanent generation. PermGen...