My Oracle Support Banner

Java SE 8 Metaspace Occupancy Grows up to the Limit when Using JAXB (Doc ID 2355899.1)

Last updated on NOVEMBER 08, 2020

Applies to:

Java SE JDK and JRE - Version 8 and later
Information in this document applies to any platform.


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:

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 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:

<JAVA_HOME>\bin>.\xjc.exe -version
xjc 2.2.8-b130911.1802





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

My Oracle Support provides customers with access to over a million knowledge articles and a vibrant support community of peers and Oracle experts.