Return-Path: Delivered-To: apmail-lucene-java-user-archive@www.apache.org Received: (qmail 8405 invoked from network); 8 Jul 2008 09:57:31 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 8 Jul 2008 09:57:31 -0000 Received: (qmail 69218 invoked by uid 500); 8 Jul 2008 09:57:26 -0000 Delivered-To: apmail-lucene-java-user-archive@lucene.apache.org Received: (qmail 69191 invoked by uid 500); 8 Jul 2008 09:57:26 -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 69179 invoked by uid 99); 8 Jul 2008 09:57:26 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 08 Jul 2008 02:57:26 -0700 X-ASF-Spam-Status: No, hits=3.2 required=10.0 tests=SPF_NEUTRAL,URIBL_BLACK X-Spam-Check-By: apache.org Received-SPF: neutral (athena.apache.org: local policy) Received: from [74.125.46.30] (HELO yw-out-2324.google.com) (74.125.46.30) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 08 Jul 2008 09:56:32 +0000 Received: by yw-out-2324.google.com with SMTP id 3so1043169ywj.5 for ; Tue, 08 Jul 2008 02:56:46 -0700 (PDT) Received: by 10.151.155.9 with SMTP id h9mr10015383ybo.130.1215511006515; Tue, 08 Jul 2008 02:56:46 -0700 (PDT) Received: from ?10.17.4.4? ( [72.93.214.93]) by mx.google.com with ESMTPS id 5sm974838ywd.8.2008.07.08.02.56.45 (version=TLSv1/SSLv3 cipher=RC4-MD5); Tue, 08 Jul 2008 02:56:46 -0700 (PDT) Message-Id: From: Michael McCandless To: java-user@lucene.apache.org In-Reply-To: <48731EC4.5050404@fastmail.fm> Content-Type: text/plain; charset=US-ASCII; format=flowed; delsp=yes Content-Transfer-Encoding: 7bit Mime-Version: 1.0 (Apple Message framework v926) Subject: Re: Move from RAMDirectory to FSDirectory causing problem sometimes Date: Tue, 8 Jul 2008 05:56:44 -0400 References: <48731EC4.5050404@fastmail.fm> X-Mailer: Apple Mail (2.926) X-Virus-Checked: Checked by ClamAV on apache.org Technically you should call directory.close() as well, but missing that will not lead to too many open files. How often is that RuntimeException being thrown? EG if a single document is frequently hitting an exception during analysis, your code doesn't close the IndexWriter in that situation. It's better to use a try/finally and close the IndexWriter in the finally clause, to cover that case. Are you sure nothing else is using up file descriptors? EG the createDocument call does not open any files? Mike Paul Taylor wrote: > Hi, I have been using a RAMDirectory for indexing without any > problem, but I then moved to a file based directory to reduce memory > usage. this has been working fine on Windows and OSX and my version > of linux (redhat) but is failing on a version of linux (archlinux) > with 'Too many files opened' , but they are only indexing 32 > documents , I can index thousands without a problem. It mentions > this error in the Lucene FAQ but I am not dealing directly with the > filesystem myself, this is my code for creating an index is it okay > or is there some kind of close that I am missing > > thanks for any help Paul > > public synchronized void reindex() > { > MainWindow.logger.info("Reindex start:" + new Date()); > TableModel tableModel = table.getModel(); > try > { > //Recreate the RAMDirectory uses too much memory > //directory = new RAMDirectory(); > directory = > FSDirectory.getDirectory(Platform.getPlatformLicenseFolder()+ "/" + > TAG_BROWSER_INDEX); > IndexWriter writer = new IndexWriter(directory, analyzer, > true); > > //Iterate through all rows > for (int row = 0; row < tableModel.getRowCount(); row++) > { > //for each row make a new document > Document document = createDocument(row); > writer.addDocument(document); > > } > writer.optimize(); > writer.close(); > } > catch (Exception e) > { > throw new RuntimeException("Problem indexing Data:" + > e.getMessage()); > } > } > > --------------------------------------------------------------------- > To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org > For additional commands, e-mail: java-user-help@lucene.apache.org > --------------------------------------------------------------------- To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org For additional commands, e-mail: java-user-help@lucene.apache.org