Return-Path: Delivered-To: apmail-commons-issues-archive@locus.apache.org Received: (qmail 87307 invoked from network); 24 Apr 2008 15:52:02 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 24 Apr 2008 15:52:02 -0000 Received: (qmail 83421 invoked by uid 500); 24 Apr 2008 15:50:59 -0000 Delivered-To: apmail-commons-issues-archive@commons.apache.org Received: (qmail 83346 invoked by uid 500); 24 Apr 2008 15:50:59 -0000 Mailing-List: contact issues-help@commons.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: issues@commons.apache.org Delivered-To: mailing list issues@commons.apache.org Received: (qmail 83335 invoked by uid 99); 24 Apr 2008 15:50:59 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 24 Apr 2008 08:50:59 -0700 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.140] (HELO brutus.apache.org) (140.211.11.140) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 24 Apr 2008 15:50:14 +0000 Received: from brutus (localhost [127.0.0.1]) by brutus.apache.org (Postfix) with ESMTP id D78A3234C103 for ; Thu, 24 Apr 2008 08:47:21 -0700 (PDT) Message-ID: <851400911.1209052041881.JavaMail.jira@brutus> Date: Thu, 24 Apr 2008 08:47:21 -0700 (PDT) From: "Clebert Rezende Suconic (JIRA)" To: issues@commons.apache.org Subject: [jira] Commented: (BEANUTILS-291) Circular Reference on WeakHashMap In-Reply-To: <22722095.1186446839070.JavaMail.jira@brutus> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-Virus-Checked: Checked by ClamAV on apache.org [ https://issues.apache.org/jira/browse/BEANUTILS-291?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12592108#action_12592108 ] Clebert Rezende Suconic commented on BEANUTILS-291: --------------------------------------------------- What about creating a new WeahHashMap without extending FastHashMap, and propose this fix to Common Collections for a future release? > Circular Reference on WeakHashMap > --------------------------------- > > Key: BEANUTILS-291 > URL: https://issues.apache.org/jira/browse/BEANUTILS-291 > Project: Commons BeanUtils > Issue Type: Bug > Components: Bean / Property Utils > Affects Versions: 1.8.0-BETA > Reporter: Niall Pemberton > Fix For: 1.8.0 > > Attachments: BEANUTILS-291-FixMemoryLeaks-v2.patch, memoryLeakTests-new.zip, PropertyUtilsBean.java, ThreadIsolationAndTestImprovement2.patch > > > Clebert Suconic wrote on the dev@commons list .... > (see http://tinyurl.com/2a9gan) > I have been investigating WeakHashMaps on BeanUtils 1.8 as part of a investigation on this: > http://jira.jboss.com/jira/browse/JBAS-2299 > (Which is not actually an issue with JBAS, but an issue when using BeanUtils as part of the classPath). > There is a circular reference on the WeakHashMap, The WeakHashMap will have the ClassLoader as the key, and it will have a reference back to the Key from one of the Reflection objects. This doesn't work! (Please.. no discussions about this point.. if you don't believe me, do some testing with simple stuff before discussing this and come back to me only after that) > org.jboss.web.tomcat.service.WebAppClassLoader@16334564 > !--- sun.reflect.DelegatingClassLoader@27651708 > !--- !--- class sun.reflect.GeneratedConstructorAccessor38 > !--- !--- !--- [Ljava.lang.Object;@10800875 > !--- !--- !--- !--- java.util.Vector@838806 > !--- !--- !--- !--- !--- sun.reflect.DelegatingClassLoader@27651708 > !--- !--- !--- !--- !--- !--- class sun.reflect.GeneratedConstructorAccessor38 > !--- !--- !--- !--- !--- !--- !--- class java.lang.Class > !--- !--- !--- !--- !--- !--- !--- !--- org.apache.commons.beanutils.converters.ClassConverter@22616909 > !--- !--- !--- !--- !--- !--- !--- !--- !--- org.apache.commons.beanutils.converters.ArrayConverter@18888821 > !--- !--- !--- !--- !--- !--- !--- !--- !--- !--- org.apache.commons.beanutils.converters.ConverterFacade@13619754 > !--- !--- !--- !--- !--- !--- !--- !--- !--- !--- !--- java.util.HashMap$Entry@32434103 > !--- !--- !--- !--- !--- !--- !--- !--- !--- !--- !--- !--- [Ljava.util.HashMap$Entry;@28236766 > !--- !--- !--- !--- !--- !--- !--- !--- !--- !--- !--- !--- !--- java.util.HashMap@14997495 > !--- !--- !--- !--- !--- !--- !--- !--- !--- !--- !--- !--- !--- !--- org.apache.commons.beanutils.ConvertUtilsBean@2016953 > !--- !--- !--- !--- !--- !--- !--- !--- !--- !--- !--- !--- !--- !--- !--- org.apache.commons.beanutils.BeanUtilsBean@30487951 > !--- !--- !--- !--- !--- !--- !--- !--- !-- -!--- !--- !--- !--- !--- !--- !---FieldReference private java.lang.Object java.util.WeakHashMap$Entry.value=java.util.WeakHashMap$Entry@23775534 Detail > I don't know if I'm preaching to the choir, but just in case this is new information to someone... you should aways keep Reflection referenced as SoftReferences (if you really have to). Reflection is aways a new object so a WeakReference is too weak. > On JBossSerialization I have solved this using an interesting way. I called it PersistentReference. I'm using SoftReferences, and keeping the information to recreate it case the SoftReference is cleared: > http://fisheye.jboss.org/browse/JBoss/jboss-serialization/src/org/jboss/serial/references/PersistentReference.java?r=1.3 > And also... you guys should write a testcase to validate if the Caching is being cleared. (I don't know if you have one). > http://anonsvn.jboss.org/repos/jbossserialization/trunk/tests/org/jboss/serial/memory/MemoryLeakTestCase.java > You don't need to use the jboss-profiler API for this.. just create a WeakReference to a new ClassLoader, and validate if it was released at the end after some exercizing some code on this caching. You will > probably need to fill your memory almost to 100% on the test as SoftReference are only gone when the memory is low. -- This message is automatically generated by JIRA. - You can reply to this email to add a comment to the issue online.