Return-Path: Delivered-To: apmail-jakarta-lucene-user-archive@www.apache.org Received: (qmail 50253 invoked from network); 13 Sep 2004 13:06:27 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur-2.apache.org with SMTP; 13 Sep 2004 13:06:27 -0000 Received: (qmail 53882 invoked by uid 500); 13 Sep 2004 13:06:15 -0000 Delivered-To: apmail-jakarta-lucene-user-archive@jakarta.apache.org Received: (qmail 53842 invoked by uid 500); 13 Sep 2004 13:06:14 -0000 Mailing-List: contact lucene-user-help@jakarta.apache.org; run by ezmlm Precedence: bulk List-Unsubscribe: List-Subscribe: List-Help: List-Post: List-Id: "Lucene Users List" Reply-To: "Lucene Users List" Delivered-To: mailing list lucene-user@jakarta.apache.org Received: (qmail 53828 invoked by uid 99); 13 Sep 2004 13:06:14 -0000 X-ASF-Spam-Status: No, hits=0.0 required=10.0 tests= X-Spam-Check-By: apache.org Received-SPF: pass (hermes.apache.org: local policy) Received: from [195.47.73.164] (HELO msx-na-server.forrest.local) (195.47.73.164) by apache.org (qpsmtpd/0.28) with ESMTP; Mon, 13 Sep 2004 06:06:11 -0700 X-MimeOLE: Produced By Microsoft Exchange V6.0.6375.0 content-class: urn:content-classes:message MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-2" Content-Transfer-Encoding: quoted-printable Subject: OutOfMemory example Date: Mon, 13 Sep 2004 15:06:31 +0200 Message-ID: X-MS-Has-Attach: X-MS-TNEF-Correlator: Thread-Topic: OutOfMemory example Thread-Index: AcSZknx4TYhtTDbdRLCXWOWeLKBS2A== From: =?iso-8859-2?B?Smn47SBLdWhu?= To: X-Virus-Checked: Checked X-Spam-Rating: minotaur-2.apache.org 1.6.2 0/1000/N Hi, I think I can reproduce memory leaking problem while reopening an = index. Lucene version tested is 1.4.1, version 1.4 final works OK. My = JVM is: $ java -version java version "1.4.2_05" Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_05-b04) Java HotSpot(TM) Client VM (build 1.4.2_05-b04, mixed mode) The code you can test is below, there are only 3 iterations for me if I = use -Xmx5m, the 4th fails. Jiri. package test; import org.apache.lucene.analysis.standard.StandardAnalyzer; import org.apache.lucene.document.Document; import org.apache.lucene.document.Field; import org.apache.lucene.index.IndexReader; import org.apache.lucene.index.IndexWriter; import org.apache.lucene.index.Term; import org.apache.lucene.search.Hits; import org.apache.lucene.search.IndexSearcher; import org.apache.lucene.search.Searcher; import org.apache.lucene.search.Sort; import org.apache.lucene.search.SortField; import org.apache.lucene.search.TermQuery; import org.apache.lucene.store.Directory; import org.apache.lucene.store.RAMDirectory; import java.io.IOException; import java.text.SimpleDateFormat; import java.util.Calendar; import java.util.Date; /** * Run this test with Lucene 1.4.1 and -Xmx5m */ public class ReopenTest { private static long mem_last =3D 0; public static void main(String[] args) throws IOException { Directory directory =3D create_index(); for (int i =3D 1; i < 100; i++) { System.err.println("loop " + i); search_index(directory); } } private static void search_index(Directory directory) throws = IOException { IndexReader reader =3D IndexReader.open(directory); Searcher searcher =3D new IndexSearcher(reader); print_mem("search 1"); SortField[] fields =3D new SortField[2]; fields[0] =3D new SortField("date", SortField.STRING, true); fields[1] =3D new SortField("id", SortField.STRING, false); Sort sort =3D new Sort(fields); TermQuery query =3D new TermQuery(new Term("text", "\"text = 5\"")); print_mem("search 2"); Hits hits =3D searcher.search(query, sort); print_mem("search 3"); for (int i =3D 0; i < hits.length(); i++) { Document doc =3D hits.doc(i); System.out.println("doc " + i + ": " + doc.toString()); } print_mem("search 4"); searcher.close(); reader.close(); } private static void print_mem(String log) { long mem_free =3D Runtime.getRuntime().freeMemory(); long mem_total =3D Runtime.getRuntime().totalMemory(); long mem_max =3D Runtime.getRuntime().maxMemory(); long delta =3D (mem_last - mem_free) * -1; System.out.println(log + "=3D delta: " + delta + ", free: " + = mem_free + ", used: " +=20 (mem_total-mem_free) + ", total: " + mem_total + ", max: " + mem_max); mem_last =3D mem_free; } private static Directory create_index() throws IOException { print_mem("create 1"); Directory directory =3D new RAMDirectory(); Calendar c =3D Calendar.getInstance(); SimpleDateFormat df =3D new SimpleDateFormat("yyyy-MM-dd"); IndexWriter writer =3D new IndexWriter(directory, new = StandardAnalyzer(), true); for (int i =3D 0; i < 365 * 30; i++) { Document doc =3D new Document(); doc.add(Field.Keyword("date", df.format(new = Date(c.getTimeInMillis())))); doc.add(Field.Keyword("id", "AB" + String.valueOf(i))); doc.add(Field.Text("text", "Tohle je text " + i)); writer.addDocument(doc); c.add(Calendar.DAY_OF_YEAR, 1); } writer.optimize(); System.err.println("index size: " + writer.docCount()); writer.close(); print_mem("create 2"); return directory; } } --------------------------------------------------------------------- To unsubscribe, e-mail: lucene-user-unsubscribe@jakarta.apache.org For additional commands, e-mail: lucene-user-help@jakarta.apache.org