When Using an Older JAXB Version, Java SE 8 Metaspace Grows to its Maximum Size Limit
(Doc ID 2355899.1)
Last updated on MARCH 31, 2023
Applies to:
Java SE JDK and JRE - Version 8 and laterInformation in this document applies to any platform.
Symptoms
After migrating from Java SE 7 to Java SE 8, an application that uses JAXB sees Metaspace usage growing constantly. This possibly results in one of the following:
- The Metaspace size limit is reached (if the MaxMetaspaceSize option has been set to define an upper limit on the Metaspace size). The effect of this can be:
- The garbage collector may run full Garbage Collections (Full GCs) constantly, freeing enough Metaspace to make some progress, only to cycle back into another Full GC when it fills again. This can be seen as a significant performance issue for the application.
- OutOfMemoryError: Metaspace
- The system runs out of memory.
This Java SE 8 behavior appears as a Metaspace memory leak. It is contrary to the behavior seen with the Java SE 7 Permanent Generation (PermGen) mechanism, where PermGen occupancy stays at nearly the same level throughout the application lifecycle.
Investigation reveals that considerable Metaspace usage is coming from JAXB and certain JAXBContext usage patterns, where new JAXBContext is created back and forth. The issue does not occur with the JAXB library provided with the JDK 8 distribution, but does occur when using the external JAXB 2.1.9 version.
To verify the JAXB version included with a particular JDK version, simply run $JDK_HOME/bin/xjc -version or, on Windows, $JDK_HOME\bin\xjc.exe -version. Sample output from JDK 8u162:
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 |
Cause |
Solution |