Return-Path: X-Original-To: apmail-jackrabbit-dev-archive@www.apache.org Delivered-To: apmail-jackrabbit-dev-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 319569344 for ; Tue, 22 Nov 2011 22:49:05 +0000 (UTC) Received: (qmail 275 invoked by uid 500); 22 Nov 2011 22:49:04 -0000 Delivered-To: apmail-jackrabbit-dev-archive@jackrabbit.apache.org Received: (qmail 198 invoked by uid 500); 22 Nov 2011 22:49:04 -0000 Mailing-List: contact dev-help@jackrabbit.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@jackrabbit.apache.org Delivered-To: mailing list dev@jackrabbit.apache.org Received: (qmail 145 invoked by uid 99); 22 Nov 2011 22:49:04 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 22 Nov 2011 22:49:04 +0000 X-ASF-Spam-Status: No, hits=-2001.2 required=5.0 tests=ALL_TRUSTED,RP_MATCHES_RCVD X-Spam-Check-By: apache.org Received: from [140.211.11.116] (HELO hel.zones.apache.org) (140.211.11.116) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 22 Nov 2011 22:49:01 +0000 Received: from hel.zones.apache.org (hel.zones.apache.org [140.211.11.116]) by hel.zones.apache.org (Postfix) with ESMTP id 6934698223 for ; Tue, 22 Nov 2011 22:48:40 +0000 (UTC) Date: Tue, 22 Nov 2011 22:48:40 +0000 (UTC) From: "Alex Parvulescu (Commented) (JIRA)" To: dev@jackrabbit.apache.org Message-ID: <175184502.4306.1322002120432.JavaMail.tomcat@hel.zones.apache.org> In-Reply-To: <1042062885.2579.1321970441229.JavaMail.tomcat@hel.zones.apache.org> Subject: [jira] [Commented] (JCR-3151) SharedFieldCache can cause a memory leak MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 X-Virus-Checked: Checked by ClamAV on apache.org [ https://issues.apache.org/jira/browse/JCR-3151?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13155528#comment-13155528 ] Alex Parvulescu commented on JCR-3151: -------------------------------------- > The patch might break things in the situation where different ValueIndex instances should go into the cache for the same field and same prefix but a for a different FieldComparator implementation: despite different, both ValueIndex instances end up at the same cache slot. Agreed, what I cannot understand is the relation between the ValueIndex and the provided field comparator implementation. To me they are 2 different things. Just look at how the ValueIndex cache is being build. So I'm not sure if them "ending up at the same cache slot" is actually a bad thing :) > SharedFieldCache can cause a memory leak > ---------------------------------------- > > Key: JCR-3151 > URL: https://issues.apache.org/jira/browse/JCR-3151 > Project: Jackrabbit Content Repository > Issue Type: Bug > Components: jackrabbit-core > Reporter: Alex Parvulescu > Attachments: JCR-3151.patch > > > The SharedFieldCache has some problems with the way it builds the cache: > - as key is has the IndexReader > - as value it has a inner cache (another map) that has as a key a static inner class called 'Key'. > This 'Key' holds a reference to the comparator used for in the queries ran. > Assuming this comparator is of any type that extends from AbstractFieldComparator (I think all of the custom JR comparators), then it keeps a reference to all the InderReader instances in order to be able to load the values as Comparable(s). > So the circle is complete and the SharedFieldCache entries never get GC'ed. > One option would have been to implement a 'purge' method on the cache, similar to the lucene mechanism, and when an InderReader gets closed is could call 'purge'. But that is both ugly AND is doesn't seem to work that well :) > A more radical option is to remove the cache completely. Each instance of SimpleFieldComparator (the only client of this cache) already builds an array of the available values, so the cache would only help other instances of the same type. We'll not analyze this further. > The proposed solution (patch will follow shortly) is to remove the Comparator reference from the Key class. > It looks like it has no real purpose there, just to impact the 'equals' of the key, which makes no sense in the first place as the lucene query does not use the Comparator info at all. > If anything, using the same field and 2 different Comparators we'll get 2 different cache entries based on the same values from the lucene index. > Feedback is appreciated! -- 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