Java SE Permanent Generation or Metaspace Gets Filled with sun.reflect.Generated*Accessor Classes
(Doc ID 1669883.1)
Last updated on NOVEMBER 12, 2023
Applies to:
Java SE JDK and JRE - Version 5 to 8Information in this document applies to any platform.
Symptoms
Applications or frameworks that frequently use the Reflection API can generate numerous Reflection Accessor classes. For example:
sun.reflect.GeneratedMethodAccessor<Number>
sun.reflect.GeneratedConstructorAccessor<Number>
sun.reflect.GeneratedSerializationConstructorAccessor<Number>
As is the case for all loaded classes, the JVM allocates memory for these dynamically generated classes from the JVM-managed memory pool that holds classes and their metadata (class memory pool). In JDK 7, this memory pool is called the "Permanent Generation" or "PermGen" for short. In JDK 8, it is called the "Metaspace." Numerous memory allocations for these dynamically generated classes may lead to the following situations:
- Frequent Full GCs that unload many sun.reflect.Generated*Accessor classes. This occurs when the class memory pool reaches its maximum size and needs to be collected. The following are example GC log entries for this type of collection:
JDK 7:
- Fragmentation of the memory pool, resulting in less of the memory pool being useful for allocations
Changes
Cause
To view full details, sign in with your My Oracle Support account. |
|
Don't have a My Oracle Support account? Click to get started! |
In this Document
Symptoms |
Changes |
Cause |
Solution |
References |