You are viewing a plain text version of this content. The canonical link for it is here.
Posted to log4j-dev@logging.apache.org by "Remko Popma (JIRA)" <ji...@apache.org> on 2015/10/24 21:04:27 UTC

[jira] [Updated] (LOG4J2-1176) First loaded web app has memory leak in Tomcat when log4j jars are in $catalina.home/lib folder

     [ https://issues.apache.org/jira/browse/LOG4J2-1176?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Remko Popma updated LOG4J2-1176:
--------------------------------
    Description: 
When the log4j2 jar files are in $catalina.home/lib, the first web application that is loaded will be reported by Tomcat as having a memory leak from loaded classes. 

*1. Steps to reproduce*
# Install Tomcat 7.0.65 afresh
# Copy log4j-api-2.5-SNAPSHOT.jar, log4j-core-2.5-SNAPSHOT.jar, log4j-web-2.5-SNAPSHOT.jar into $catalina.home/lib.
# Edit $catalina.home/conf/catalina.properties: add {{log4j2.disable.jmx=true}}
# Edit $catalina.home/conf/tomcat-users.xml to give yourself permission to access the Tomcat Web App Manager
# Start Tomcat
# Open the [Manager App|http://localhost:8080/manager/html]
# Reload the Tomcat Documentation (/docs) web app
# Click the "Find Leaks" button under Diagnostics at the bottom of the Manager App page

The following warning is displayed:

{quote}
The following web applications were stopped (reloaded, undeployed), but their classes from previous runs are still loaded in memory, thus causing a memory leak (use a profiler to confirm):
/docs
{quote}

The same problem also happens if a log4j2.xml config file is placed in $catalina.home/lib. Set status="true" in the configuration to confirm that the web app that is loaded first causes this warning.

*2. With custom web app*
Use the attached web app to test the order of deployment.
# Restart Tomcat
# Deploy web app (containing log4j2.xml)
# Restart Tomcat again (note that the custom web app is loaded first)
# Reload /docs app: no memory leak
# Reload /webapp: gives memory leak warning

Different order:
# Undeploy custom web app
# Restart Tomcat ( /docs web app is loaded first)
# Deploy custom web app
# Reload /docs app: gives memory leak warning
# Reload /webapp: no memory leak

I have tried to use [Eclipse Memory Analyzer|https://eclipse.org/mat/] to find out where the leak is, but without success. 

(Note that the problem also happens with the default configuration (when no log4j2.xml config is found), this may narrow things down a little...)

  was:
When the log4j2 jar files are in $catalina.home/lib, the first web application that is deployed will be reported by Tomcat as having a memory leak from loaded classes. 

*1. Steps to reproduce*
# Install Tomcat 7.0.65 afresh
# Copy log4j-api-2.5-SNAPSHOT.jar, log4j-core-2.5-SNAPSHOT.jar, log4j-web-2.5-SNAPSHOT.jar into $catalina.home/lib.
# Edit $catalina.home/conf/catalina.properties: add {{log4j2.disable.jmx=true}}
# Edit $catalina.home/conf/tomcat-users.xml to give yourself permission to access the Tomcat Web App Manager
# Start Tomcat
# Open the [Manager App|http://localhost:8080/manager/html]
# Reload the Tomcat Documentation (/docs) web app
# Click the "Find Leaks" button under Diagnostics at the bottom of the Manager App page

The following warning is displayed:

{quote}
The following web applications were stopped (reloaded, undeployed), but their classes from previous runs are still loaded in memory, thus causing a memory leak (use a profiler to confirm):
/docs
{quote}

The same problem also happens if a log4j2.xml config file is placed in $catalina.home/lib. Set status="true" in the configuration to confirm that the web app that is deployed first causes this warning.

*2. With custom web app*
Use the attached web app to test the order of deployment.
# Restart Tomcat
# Deploy web app (containing log4j2.xml)
# Restart Tomcat again (note that the custom web app is loaded first)
# Reload /docs app: no memory leak
# Reload /webapp: gives memory leak warning

Different order:
# Undeploy custom web app
# Restart Tomcat ( /docs web app is loaded first)
# Deploy custom web app
# Reload /docs app: gives memory leak warning
# Reload /webapp: no memory leak

I have tried to use [Eclipse Memory Analyzer|https://eclipse.org/mat/] to find out where the leak is, but without success. 

(Note that the problem also happens with the default configuration (when no log4j2.xml config is found), this may narrow things down a little...)

        Summary: First loaded web app has memory leak in Tomcat when log4j jars are in $catalina.home/lib folder  (was: Memory leak in Tomcat when log4j jars are in $catalina.home/lib folder)

> First loaded web app has memory leak in Tomcat when log4j jars are in $catalina.home/lib folder
> -----------------------------------------------------------------------------------------------
>
>                 Key: LOG4J2-1176
>                 URL: https://issues.apache.org/jira/browse/LOG4J2-1176
>             Project: Log4j 2
>          Issue Type: Bug
>          Components: Configurators, Web/Servlet
>    Affects Versions: 2.4.1, 2.5
>         Environment: Tomcat 7.0.50 or Tomcat 7.0.65, jdk1.8.0_51, Win 10
>            Reporter: Remko Popma
>             Fix For: 2.5
>
>         Attachments: webapp.war
>
>
> When the log4j2 jar files are in $catalina.home/lib, the first web application that is loaded will be reported by Tomcat as having a memory leak from loaded classes. 
> *1. Steps to reproduce*
> # Install Tomcat 7.0.65 afresh
> # Copy log4j-api-2.5-SNAPSHOT.jar, log4j-core-2.5-SNAPSHOT.jar, log4j-web-2.5-SNAPSHOT.jar into $catalina.home/lib.
> # Edit $catalina.home/conf/catalina.properties: add {{log4j2.disable.jmx=true}}
> # Edit $catalina.home/conf/tomcat-users.xml to give yourself permission to access the Tomcat Web App Manager
> # Start Tomcat
> # Open the [Manager App|http://localhost:8080/manager/html]
> # Reload the Tomcat Documentation (/docs) web app
> # Click the "Find Leaks" button under Diagnostics at the bottom of the Manager App page
> The following warning is displayed:
> {quote}
> The following web applications were stopped (reloaded, undeployed), but their classes from previous runs are still loaded in memory, thus causing a memory leak (use a profiler to confirm):
> /docs
> {quote}
> The same problem also happens if a log4j2.xml config file is placed in $catalina.home/lib. Set status="true" in the configuration to confirm that the web app that is loaded first causes this warning.
> *2. With custom web app*
> Use the attached web app to test the order of deployment.
> # Restart Tomcat
> # Deploy web app (containing log4j2.xml)
> # Restart Tomcat again (note that the custom web app is loaded first)
> # Reload /docs app: no memory leak
> # Reload /webapp: gives memory leak warning
> Different order:
> # Undeploy custom web app
> # Restart Tomcat ( /docs web app is loaded first)
> # Deploy custom web app
> # Reload /docs app: gives memory leak warning
> # Reload /webapp: no memory leak
> I have tried to use [Eclipse Memory Analyzer|https://eclipse.org/mat/] to find out where the leak is, but without success. 
> (Note that the problem also happens with the default configuration (when no log4j2.xml config is found), this may narrow things down a little...)



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-dev-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-dev-help@logging.apache.org