Return-Path: X-Original-To: apmail-lucene-java-user-archive@www.apache.org Delivered-To: apmail-lucene-java-user-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 98E689C18 for ; Wed, 1 Feb 2012 02:42:53 +0000 (UTC) Received: (qmail 78016 invoked by uid 500); 1 Feb 2012 02:42:51 -0000 Delivered-To: apmail-lucene-java-user-archive@lucene.apache.org Received: (qmail 77449 invoked by uid 500); 1 Feb 2012 02:42:43 -0000 Mailing-List: contact java-user-help@lucene.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: java-user@lucene.apache.org Delivered-To: mailing list java-user@lucene.apache.org Received: (qmail 77441 invoked by uid 99); 1 Feb 2012 02:42:40 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 01 Feb 2012 02:42:40 +0000 X-ASF-Spam-Status: No, hits=-0.7 required=5.0 tests=RCVD_IN_DNSWL_LOW,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of trejkaz@trypticon.org designates 209.85.160.176 as permitted sender) Received: from [209.85.160.176] (HELO mail-gy0-f176.google.com) (209.85.160.176) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 01 Feb 2012 02:42:32 +0000 Received: by ghbz2 with SMTP id z2so454351ghb.35 for ; Tue, 31 Jan 2012 18:42:12 -0800 (PST) Received: by 10.236.154.232 with SMTP id h68mr39829361yhk.51.1328064132281; Tue, 31 Jan 2012 18:42:12 -0800 (PST) Received: from mail-qy0-f176.google.com (mail-qy0-f176.google.com [209.85.216.176]) by mx.google.com with ESMTPS id v7sm41703159yhi.1.2012.01.31.18.42.11 (version=SSLv3 cipher=OTHER); Tue, 31 Jan 2012 18:42:11 -0800 (PST) Received: by qcsd1 with SMTP id d1so509532qcs.35 for ; Tue, 31 Jan 2012 18:42:11 -0800 (PST) MIME-Version: 1.0 Received: by 10.229.76.149 with SMTP id c21mr9561492qck.5.1328064131163; Tue, 31 Jan 2012 18:42:11 -0800 (PST) Received: by 10.229.229.13 with HTTP; Tue, 31 Jan 2012 18:42:11 -0800 (PST) In-Reply-To: References: Date: Wed, 1 Feb 2012 13:42:11 +1100 Message-ID: Subject: Re: Lucene appears to use memory maps after unmapping them From: Trejkaz To: java-user@lucene.apache.org Content-Type: text/plain; charset=UTF-8 On Wed, Feb 1, 2012 at 1:14 PM, Robert Muir wrote: > > No, I don't think you should use close at all, because your problem is > you are calling close() when its unsafe to do so (you still have other > threads that try to search the reader after you closed it). > > Instead of trying to fix the bugs in your code, I suggested using > SearcherManager, which uses IndexReaders reference counting API (or > you can use that directly alternatively). So when we close() our own TextIndex wrapper class, it would call decRef() - but if another thread is still using the index, this call to decRef() wouldn't actually close the reader. IMO, this wouldn't really satisfy the meaning of "close" for the TextIndex. Rather, I would prefer to track who is currently using it (which is similar to reference counting) and throw some exception which points the finger at some code which hasn't correctly terminated so that it can be fixed. After all, we don't close the text index until after all the GUI components have been closed. Each of those is supposed to clean itself up, which includes cancelling any tasks which might be accessing the text index. If any searches are still going on by the time it gets to close(), there is a bug somewhere. TX P.S. Why is the SearcherManager API written in such a way that it makes it easy to fail to return the searcher? Wouldn't it make more sense to design it like this? manager.execute(new IndexSearcherLogic() { public void withSearcher(IndexSearcher searcher) throws IOException { // .. logic which might well throw an exception } }); This way if their block throws an exception you're not relying on them remembering to release it in a finally block and it makes it nearly impossible to do the wrong thing. --------------------------------------------------------------------- To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org For additional commands, e-mail: java-user-help@lucene.apache.org