You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by "Bernd Eckenfels (JIRA)" <ji...@apache.org> on 2014/11/18 05:34:33 UTC

[jira] [Commented] (VFS-309) ThreadLocal memory leak in DefaultFileContent

    [ https://issues.apache.org/jira/browse/VFS-309?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14215696#comment-14215696 ] 

Bernd Eckenfels commented on VFS-309:
-------------------------------------

As commented in VFS-142 there are two problems. One is leaking when you close the file content, this is fixed by the (attached and commited) patch. However the other problem is, that even when all streams are closed, the FileContentThreadData is not removed (there has been a patch but it seems to be not fully commited to VFS2).

I suggest closing VFS-142 to document the setNull()->remove() fix and keep this bug about the need (and impossibility in some cases) for closing FileContent.

> ThreadLocal memory leak in DefaultFileContent
> ---------------------------------------------
>
>                 Key: VFS-309
>                 URL: https://issues.apache.org/jira/browse/VFS-309
>             Project: Commons VFS
>          Issue Type: Bug
>    Affects Versions: 2.0
>         Environment: Tomcat servlet container
>            Reporter: jontro
>         Attachments: threadlocal_setNull_vs_remove_bug.patch
>
>
> When using commons vfs in a servlet container the ThreadLocal values stored will not be released once the request finishes.
> There needs to be a method to clear these values otherwise the data will leak into the next request.
> This was detected with tomcat 6.0.26. Upon undeploying an app that uses commons vfs tomcat detects the leaks with a huge amount of the following messages:
> A web application created a ThreadLocal with key of type [java.lang.ThreadLocal] (value [java.lang.ThreadLocal@52fb241d]) and a value of type [org.apache.commons.vfs.provider.FileContentThreadData] (value [org.apache.commons.vfs.provider.FileContentThreadData@6600167a]) but failed to remove it when the web application was stopped. To prevent a memory leak, the ThreadLocal has been forcibly removed.



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