Sunday, November 19, 2017

How to solve Wildfly 10 Memory Leak Issue?

You have to increase your heap memory. For this
Edit bin/standalone.conf configuration file, look for the first occurrence of JAVA_OPTS.
Then change the -Xmx option as you need.

If you use Java 8, then

Change:
JAVA_OPTS=”-Xms64m -Xmx512m -XX:MetaspaceSize=96M -XX:MaxMetaspaceSize=256m -Djava.net.preferIPv4Stack=true
To:
JAVA_OPTS=”-Xms64m -Xmx2G -XX:MetaspaceSize=96M -XX:MaxMetaspaceSize=2G -Djava.net.preferIPv4Stack=true

Resource Link:

UPDATE: Classes not unloaded after undeployment

Martin kouba stated below

  1. undeploy does not necessarily mean class unloading - it depends on JVM settings (-XX:MaxMetaspaceSize and friends for Java8)
  2. I've verified that after 50 deploy/undeploy cycles of the attached reproducer (and using -XX:MaxMetaspaceSize=128m):
for WildFly 10.0.0.Final "java.lang.OutOfMemoryError: Metaspace" occurs
for WildFly 10.1.0-SNAPSHOT (fix for WFLY-6347 merged) no OOM error occurs (metaspace is garbage collected)
After examining the heap dump I've identified the org.jboss.el.cache.BeanPropertiesCache as the root cause. In this case, it keeps a hard reference to the person.joey.test.TestClientBean class, thus effectively blocking the relevant ModuleClassLoader from GC.
Enum values are treated similarly to static constants - i.e. it's not garbage collected unless the class loader of the owner class is.
That's why person.joey.test.RequestType values remain in memory. OmniFaces only amplifies the impact - as mentioned above, it holds a reference to a BeanManager.

No comments:

Post a Comment