Java SE 8 Metaspace Occupancy Grows up to the Limit when Using JAXB

(Doc ID 2355899.1)

Last updated on MAY 01, 2018

Applies to:

Java SE JDK and JRE - Version 8 and later
Information 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:


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:

C:\Program Files\Java\jdk1.8.0_162\bin>.\xjc.exe -version
xjc 2.2.8-b130911.1802

 

Changes

 

Cause

Sign In with your My Oracle Support account

Don't have a My Oracle Support account? Click to get started

My Oracle Support provides customers with access to over a
Million Knowledge Articles and hundreds of Community platforms