You are viewing a plain text version of this content. The canonical link for it is here.
Posted to common-issues@hadoop.apache.org by "Todd Lipcon (JIRA)" <ji...@apache.org> on 2012/07/30 22:19:35 UTC

[jira] [Commented] (HADOOP-8632) Configuration leaking class-loaders

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

Todd Lipcon commented on HADOOP-8632:
-------------------------------------

Hi Costin. We added the {{CACHE_CLASSES}} member in HADOOP-6133 to solve a performance regression which we saw in practice. HADOOP-6502 also talks about another case where the performance of this code was critical. So I don't think removing the cache is a good idea. 

That said, I do think changing the cache to have weak values as well as weak keys makes sense. Guava's MapMaker has a nice utility to do this, or we could simply change the class values to be Map<String, WeakReference<Class<?>>>.
                
> Configuration leaking class-loaders
> -----------------------------------
>
>                 Key: HADOOP-8632
>                 URL: https://issues.apache.org/jira/browse/HADOOP-8632
>             Project: Hadoop Common
>          Issue Type: Bug
>          Components: conf
>    Affects Versions: 2.0.0-alpha
>            Reporter: Costin Leau
>
> The newly introduced CACHE_CLASSES leaks class loaders causing associated classes to not be reclaimed.
> One solution is to remove the cache itself since each class loader implementation caches the classes it loads automatically and preventing an exception from being raised is just a micro-optimization that, as one can tell, causes bugs instead of improving anything.
> In fact, I would argue in a highly-concurrent environment, the weakhashmap synchronization/lookup probably costs more then creating the exception itself.
> Another is to prevent the leak from occurring, by inserting the loadedclass into the WeakHashMap wrapped in a WeakReference. Otherwise the class has a strong reference to its classloader (the key) meaning neither gets GC'ed.
> And since the cache_class is static, even if the originating Configuration instance gets GC'ed, its classloader won't.

--
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