[jboss-jira] [JBoss JIRA] Commented: (JBAS-8424) RestEasy deployer won't release Weld BeanManager on undeploy

Stan Silvert (JIRA) jira-events at lists.jboss.org
Tue Sep 28 09:15:29 EDT 2010


    [ https://jira.jboss.org/browse/JBAS-8424?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12553680#action_12553680 ] 

Stan Silvert commented on JBAS-8424:
------------------------------------

It absolutely does (or did) cause a memory leak because the value could not be removed from the WeakHashMap.  A value in a WeakHashMap will not be removed if the value holds an instance of its own key.  In the case of Archive and ArchiveInfo, both had a WeakHashMap that was using the classloader instance as a key.  But the mapped value held that classloader as an instance variable so it would not be removed from the WeakHashMap by the garbage collector.  I have fixed the problem by wrapping the value in a WeakReference.

I still question the use of WeakHashMap in this case.  It will work as long as you wrap the value with the WeakReference before inserting it.  But is seems much cleaner to use a regular HashMap and clean up the strong references yourself on undeploy.  Perhaps it's just a matter of style but this bug does illuminate the pitfalls of reliance on GC behavior to do this kind of cleanup. 

> RestEasy deployer won't release Weld BeanManager on undeploy
> ------------------------------------------------------------
>
>                 Key: JBAS-8424
>                 URL: https://jira.jboss.org/browse/JBAS-8424
>             Project: JBoss Application Server
>          Issue Type: Bug
>      Security Level: Public(Everyone can see) 
>          Components: Deployers
>    Affects Versions: 6.0.0.CR1
>         Environment: JBoss AS 6.0.0-SNAPSHOT, Linux 64 bit
>            Reporter: David Allen
>            Assignee: Bill Burke
>            Priority: Blocker
>             Fix For: 6.0.0.CR1
>
>
> ThreadLocalResteasyProviderFactory in RestEasy has a reference to a CdiInjectorFactory that is not released when the application is undeployed from JBoss AS.  This CdiInjectorFactory holds a reference to a BeanManager from Weld, and thus leaks all the beans from the deployment.

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: https://jira.jboss.org/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        


More information about the jboss-jira mailing list