You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by "Henri Yandell (JIRA)" <ji...@apache.org> on 2006/12/06 10:01:24 UTC

[jira] Updated: (LANG-262) Use of enum prevents a classloader from being garbage collected resuling in out of memory exceptions.

     [ http://issues.apache.org/jira/browse/LANG-262?page=all ]

Henri Yandell updated LANG-262:
-------------------------------

    Attachment: ClassMapping.java

Not heard from Neil as to whether it fixed his problem. Understandable given that it took a couple of months to get passed 2.2 and apply the fix to SVN.

This is a research class that I _think_ shows that WeakHashMaps are okay with Classes as keys provided the ClassLoader is available for garbage collection. 

I'm a bit unsure of it though because I don't understand why accessing the class through the HashMap API is giving me null as the classes ClassLoader, yet when it was loaded it was the correct FooClassLoader.

Any thoughts? Is this proof or just crap?

> Use of enum prevents a classloader from being garbage collected resuling in out of memory exceptions.
> -----------------------------------------------------------------------------------------------------
>
>                 Key: LANG-262
>                 URL: http://issues.apache.org/jira/browse/LANG-262
>             Project: Commons Lang
>          Issue Type: Bug
>         Environment: All
>            Reporter: Neil Redway
>            Priority: Critical
>             Fix For: 2.3
>
>         Attachments: ClassMapping.java
>
>
> When an enum is created it is placed in the static hashmap - cEnumClasses.  If the enum is created from a classloader which has a limited lifetime then due to the strong reference the classloader is never garbage collected resulting in a memory leak.  
> I believe that making the cEnumClasses a WeakHashMap should resolve the problem.

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

        

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