TIBCOSoftware / jasperreports

JasperReports® - Free Java Reporting Library
https://community.jaspersoft.com/downloads/community-edition/
GNU Lesser General Public License v3.0
1.04k stars 400 forks source link

Possible memory leak in net.sf.jasperreports.engine.xml.BaseSaxParserFactory #119

Open whind opened 4 years ago

whind commented 4 years ago

Hi, I begin using Jasper Reports library recently. I use version 6.11.0. When I shutdown Tomcat(version 8.5.50), it add to log: The web application [/Example1] created a ThreadLocal with key of type [java.lang.ThreadLocal] ... com.sun.org.apache.xerces.internal.util.xmlgrammarpoolimpl@c020514}]) but failed to remove it when the web application was stopped. Threads are going to be renewed over time to try and avoid a probable memory leak. This is unwanted behavior because I sometimes redeploy application. For inspect who load this class, I used Jprofiler and saw that class xmlgrammarpoolimpl is called by: 1. javax.xml.parsers.SAXParserFactory which called by net.sf.jasperreports.engine.xml.BaseSaxParserFactory by ... by net.sf.jasperreports.engine.JasperCompileManager

  1. org.apache.catalina.loader.WebappClassLoaderBase which called by net.sf.jasperreports.engine.util.JRLoader by net.sf.jasperreports.engine.xml.BaseSaxParserFactory by .. by net.sf.jasperreports.engine.JasperCompileManager

Maybe you know how to avoid this problem, or maybe you can help solve this problem?

whind commented 4 years ago

INFO [Thread-11] org.apache.coyote.AbstractProtocol.pause Pausing ProtocolHandler ["http-nio-8080"] INFO [Thread-11] org.apache.coyote.AbstractProtocol.pause Pausing ProtocolHandler ["ajp-nio-8009"] INFO [Thread-11] org.apache.catalina.core.StandardService.stopInternal Stopping service [Catalina] INFO [localhost-startStop-2] org.apache.catalina.core.ApplicationContext.log Destroying Spring FrameworkServlet 'dispatcher' INFO [localhost-startStop-2] org.apache.catalina.core.ApplicationContext.log Closing Spring root WebApplicationContext SEVERE [localhost-startStop-2] org.apache.catalina.loader.WebappClassLoaderBase.checkThreadLocalMapForLeaks The web application [ROOT] created a ThreadLocal with key of type [java.lang.ThreadLocal] (value [java.lang.ThreadLocal@3d1bc241]) and a value of type [org.apache.commons.collections4.map.ReferenceMap] (value [{ParallelWebappClassLoader context: ROOT delegate: false ----------> Parent Classloader: java.net.URLClassLoader@2e0fa5d3 =com.sun.org.apache.xerces.internal.util.XMLGrammarPoolImpl@399b0938}]) but failed to remove it when the web application was stopped. Threads are going to be renewed over time to try and avoid a probable memory leak.

reda-alaoui commented 1 year ago

Introduced by 6e7e5817f1a4856c9debbe0c300ba72c81ecb748 .