0

We faced a metaspace leak problem in our JBoss EAP 7, and this leak occoured after every hot deployment.

After some search, I've found this: https://blog.voina.org/docker-jboss-dies-with-java-lang-outofmemoryerror-metaspace-after-several-redeploys/

It actually may be related to EHCache that save some class references and this prevent JBoss classloader from removing old classes from metaspace.

In this article the suggestion is to use the listener included in EHCache library:

net.sf.ehcache.constructs.web.ShutdownListener

Unfortunately we're using EHCache 3.2.0 and there is no such listener in that version, is there any alternative to that Listener? Or any method that does the exact same thing that I can call in "contextDestroyed" method?

thermz
  • 2,386
  • 3
  • 20
  • 28

1 Answers1

2

No such listener should be needed anymore. However, it is considered good manners to close you CacheManager when undeploying. If you are creating it in a ServletContextListener, destroying it there seems a good place.

I wouldn't bet on Ehcache for classloader memory leak but it's not impossible.

The right way to diagnose it is to undeploy and then do a heap dump and look (in a tool like VisualVM) for a package from the war that is still around, then find its classloader and finally the GC root of the classloader. Your leak will be in the chain to the GC root.

Henri
  • 5,551
  • 1
  • 22
  • 29