You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tuscany.apache.org by "Simon Laws (Updated) (JIRA)" <de...@tuscany.apache.org> on 2012/03/01 17:19:57 UTC

[jira] [Updated] (TUSCANY-3770) Tomcat 7 reports a memory leak when stopping a Tuscany webapp

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

Simon Laws updated TUSCANY-3770:
--------------------------------

    Attachment: ThreadMessageContext.java.patch

A patch for the 2.x code base. Want to do this fix separately so I can be sure I'm not messing anything up. 
                
> Tomcat 7 reports a memory leak when stopping a Tuscany webapp
> -------------------------------------------------------------
>
>                 Key: TUSCANY-3770
>                 URL: https://issues.apache.org/jira/browse/TUSCANY-3770
>             Project: Tuscany
>          Issue Type: Bug
>          Components: Java SCA Web App Integration
>    Affects Versions: Java-SCA-1.6
>            Reporter: Simon Nash
>            Assignee: Simon Nash
>             Fix For: Java-SCA-1.6.1
>
>         Attachments: ThreadMessageContext.java.patch
>
>
> On Tomcat 7, when a Tuscany webapp is stopped, the following message is displayed:
>   SEVERE: The web application [/sample-calculator-webapp] created a ThreadLocal with key of type [null] (value
>   [org.apache.tuscany.sca.core.invocation.ThreadMessageContext$1@1b071c0]) and a value of type
>   [org.apache.tuscany.sca.core.invocation.MessageImpl] (value [org.apache.tuscany.sca.core.invocation.MessageImpl@fbf51d])
>   but failed to remove it when the web application was stopped. This is very likely to create a memory leak.
> This happens because Tuscany adds a thread-local ThreadMessageContext object to every invocation thread when starting a request invocation and doesn't remove this object when the request is complete.
> There is code in WebAppServletHost.destroy() that attempts to remove this context information when the webapp is stopped.  This usually doesn't succeed in removing the context information because the ThreadLocal.remove() method only removes context information from the current thread and not from other threads.  There's no Java API for removing this information from other threads.
> The only way to remove this information is to track the completion of each request invocation and remove the context information from the current thread when the request has been completed.  The context information will be recreated for the next request on the thread.  This is very easy to implement by adding a few lines of code to the ThreadMessageContext class.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira