PermGen OOM Error Occurs on Redeploying Application Involving OpenJPA (Doc ID 1530911.1)

Last updated on JUNE 09, 2016

Applies to:

Oracle Weblogic Server - Version 10.3.5 and later
Information in this document applies to any platform.

Symptoms

On : 10.3.5 version, When repeating redeploy application, PermGen OOM Error occurs.

The issue can be reproduced at will with the following steps:

1. Build and deploy ejb30 example application.
cd <WL_HOME>\wlserver_10.3\samples\server\examples\src\examples\ejb\ejb30
<WL_HOME>\wlserver_10.3\server\bin\setWLSEnv.cmd
ant build
ant deploy

2 Redeploy application several times until OOM Error.
Using following command to redeploy ear:
java weblogic.Deployer -adminurl t3://localhost:7001 -user weblogic -password welcome1 -redeploy -name reviewService -source <WL_HOME>\wlserver_10.3\samples\server\examples\build\ejb30\reviewService.ear

During the testing, open jvisualvm to monitor permgen space usage. Every time application redeployed, click Perform GC, then click Heap Dump to acquire heap dump file.

3 Analyze heap dump using MAT(eclipse memory analyzer)
Heap dump analysis shows that OpenJPA class PCRegistry has a member variable "_meta", a type of ConcurrentReferenceHashMap, which references persist-able bean class. But it has no opportunity to remove elements from the HashMap on application undeployed. Within test case heap dump, a classloader sun.misc.Launcher$AppClassLoader @ 0xeff00a8 loaded class org.apache.openjpa.enhance.PCRegistry @ 0x25be61b8. PCRegistry object has a member variable "_meta", it is type of  ConcurrentReferenceHashMap, which keeps entry of type org.apache.openjpa.enhance.PCRegistry$Meta. org.apache.openjpa.enhance.PCRegistry$Meta has a field "fieldTypes", which is type of Class[]. The class array has a member reference to class examples.ejb.ejb30.domain.Item @ 0x28f9b758,  which is loaded by  weblogic.utils.classloaders.GenericClassLoader @ 0x10a089f0 . Because org.apache.openjpa.enhance.PCRegistry is referenced by sun.misc.Launcher$AppClassLoader and will never be unloaded even when application undeploy,  the reference to  examples.ejb.ejb30.domain.Item @ 0x28f9b758 does not be released, so does its associated class loader weblogic.utils.classloaders.GenericClassLoader @ 0x10a089f0 .

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