ActiveMQ
  1. ActiveMQ
  2. AMQ-2852

Memory leak when undeploying webapp with ActiveMQ client

    Details

    • Type: Bug Bug
    • Status: Resolved
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 5.3.2
    • Fix Version/s: 5.5.0
    • Component/s: Transport
    • Labels:
      None

      Description

      I have a web app with an ActiveMQ client. When undeploying the app, Tomcat logs the following messages.

      28.07.2010 17:44:28 org.apache.catalina.loader.WebappClassLoader clearReferencesThreads
      SCHWERWIEGEND: The web application [] appears to have started a thread named [InactivityMonitor Async Task: java.util.concurrent.ThreadPoolExecutor$Worker@c821ef] but has failed to stop it. This is very likely to create a memory leak. 
      28.07.2010 17:44:28 org.apache.catalina.loader.WebappClassLoader clearReferencesThreads
      SCHWERWIEGEND: The web application [] appears to have started a thread named [TcpSocketClose: java.util.concurrent.ThreadPoolExecutor$Worker@19ac2e3] but has failed to stop it. This is very likely to create a memory leak. 
      

      Searching for "InactivityMonitor Async Task" and "TcpSocketClose", I found org.apache.activemq.transport.tcp.TcpTransport and org.apache.activemq.transport.InactivityMonitor which both start a ThreadPoolExecutor in their static intializers but never stop them. The ThreadPoolExecutors hold references to ActiveMQ classes which hold a reference to the webapp classloader. These references prevent the webapp classes from being unloaded when the webapp is undeployed. Due to this the servlet container runs out of memory after a few redeployments.

      The ActiveMQ client should dispose all resources when being closed, including the ThreadPoolExecutors. Or to provide some methods to explicitly stop these Threads (like org.apache.activemq.thread.Scheduler.shutdown() does).

        Issue Links

          Activity

          Hide
          Julien HENRY added a comment -

          I still have this issue with ActiveMQ 5.4.1.

          Show
          Julien HENRY added a comment - I still have this issue with ActiveMQ 5.4.1.
          Hide
          Simeon added a comment -

          The same with 5.4.2

          Show
          Simeon added a comment - The same with 5.4.2
          Hide
          Simeon added a comment -

          here is the log output:

          SEVERE: The web application [/webapp] appears to have started a thread named [AMQPersistenceAdaptor Task] but has failed to stop it. This is very likely to create a memory leak.
          Dec 14, 2010 11:22:37 AM org.apache.catalina.loader.WebappClassLoader clearReferencesThreads
          SEVERE: The web application [/webapp] appears to have started a thread named [VMTransport] but has failed to stop it. This is very likely to create a memory leak.
          Dec 14, 2010 11:22:37 AM org.apache.catalina.loader.WebappClassLoader clearReferencesThreads
          SEVERE: The web application [/webapp] appears to have started a thread named [VMTransport] but has failed to stop it. This is very likely to create a memory leak.
          Dec 14, 2010 11:22:37 AM org.apache.catalina.loader.WebappClassLoader clearReferencesThreads
          SEVERE: The web application [/webapp] appears to have started a thread named [VMTransport] but has failed to stop it. This is very likely to create a memory leak.
          Dec 14, 2010 11:22:37 AM org.apache.catalina.loader.WebappClassLoader clearReferencesThreads
          SEVERE: The web application [/webapp] appears to have started a thread named [ActiveMQ Task] but has failed to stop it. This is very likely to create a memory leak.
          Dec 14, 2010 11:22:37 AM org.apache.catalina.loader.WebappClassLoader clearThreadLocalMap

          Show
          Simeon added a comment - here is the log output: SEVERE: The web application [/webapp] appears to have started a thread named [AMQPersistenceAdaptor Task] but has failed to stop it. This is very likely to create a memory leak. Dec 14, 2010 11:22:37 AM org.apache.catalina.loader.WebappClassLoader clearReferencesThreads SEVERE: The web application [/webapp] appears to have started a thread named [VMTransport] but has failed to stop it. This is very likely to create a memory leak. Dec 14, 2010 11:22:37 AM org.apache.catalina.loader.WebappClassLoader clearReferencesThreads SEVERE: The web application [/webapp] appears to have started a thread named [VMTransport] but has failed to stop it. This is very likely to create a memory leak. Dec 14, 2010 11:22:37 AM org.apache.catalina.loader.WebappClassLoader clearReferencesThreads SEVERE: The web application [/webapp] appears to have started a thread named [VMTransport] but has failed to stop it. This is very likely to create a memory leak. Dec 14, 2010 11:22:37 AM org.apache.catalina.loader.WebappClassLoader clearReferencesThreads SEVERE: The web application [/webapp] appears to have started a thread named [ActiveMQ Task] but has failed to stop it. This is very likely to create a memory leak. Dec 14, 2010 11:22:37 AM org.apache.catalina.loader.WebappClassLoader clearThreadLocalMap
          Hide
          Gary Tully added a comment -

          resolve client side issues in r1049184
          addition of org.apache.activemq.thread.DefaultThreadPools#shutdown to allow the default pool to be shutdown on undeploy.

          Show
          Gary Tully added a comment - resolve client side issues in r1049184 addition of org.apache.activemq.thread.DefaultThreadPools#shutdown to allow the default pool to be shutdown on undeploy.
          Hide
          Gary Tully added a comment -

          additional broker improvements in r1049527 - have discovery agent and network connector delegate to the common pool that can be explicitly shutdown.

          Show
          Gary Tully added a comment - additional broker improvements in r1049527 - have discovery agent and network connector delegate to the common pool that can be explicitly shutdown.
          Hide
          Gary Tully added a comment -

          still seems to be an issue with the amq persistence adapter

          SEVERE: The web application [/web-app] appears to have started a thread named [AMQPersistenceAdaptor Task] but has failed to stop it. This is very likely to create a memory leak.
          Show
          Gary Tully added a comment - still seems to be an issue with the amq persistence adapter SEVERE: The web application [/web-app] appears to have started a thread named [AMQPersistenceAdaptor Task] but has failed to stop it. This is very likely to create a memory leak.
          Hide
          Gary Tully added a comment -

          fixed up AMQStore piece in revision - http://svn.apache.org/viewvc?rev=1084633&view=rev

          Show
          Gary Tully added a comment - fixed up AMQStore piece in revision - http://svn.apache.org/viewvc?rev=1084633&view=rev
          Hide
          Dan Tran added a comment - - edited

          I am using AMQ 5.5 using embedded mode with no persistent listening for external producer connectors and consumed via VM connector. Still see the issue

          turn on persistent still see the issue ( <amq:broker useJmx="true" persistent="true" advisorySupport="false"> )

          SEVERE: The web application [/mc] appears to have started a thread named [ActiveMQ Task-20] but has failed to stop it. This is very likely to create a memory leak.

          Any suggestion?

          Show
          Dan Tran added a comment - - edited I am using AMQ 5.5 using embedded mode with no persistent listening for external producer connectors and consumed via VM connector. Still see the issue turn on persistent still see the issue ( <amq:broker useJmx="true" persistent="true" advisorySupport="false"> ) SEVERE: The web application [/mc] appears to have started a thread named [ActiveMQ Task-20] but has failed to stop it. This is very likely to create a memory leak. Any suggestion?
          Hide
          John Miller added a comment -

          The bug persists in ActiveMQ 5.5, I have created a new issue https://issues.apache.org/jira/browse/AMQ-3451.

          Show
          John Miller added a comment - The bug persists in ActiveMQ 5.5, I have created a new issue https://issues.apache.org/jira/browse/AMQ-3451 .

            People

            • Assignee:
              Gary Tully
              Reporter:
              Daniel Spilker
            • Votes:
              11 Vote for this issue
              Watchers:
              12 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Development