lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From John Moylan <jo...@rte.ie>
Subject Re: OutOfMemory example
Date Mon, 13 Sep 2004 14:52:53 GMT
http://issues.apache.org/bugzilla/show_bug.cgi?id=30628

you can close the index, but the Garbage Collector still needs to 
reclaim the memory and it may be taking longer than your loop to do so.

John

Jiří Kuhn wrote:
> I disagree or I don't understand. 
> 
> I can change the code as it is shown below. Now I must reopen the index to see the changes,
but the memory problem remains. I realy don't know what I'm doing wrong, the code is so simple.
> 
> Jiri.
> 
> 	...
> 
>     public static void main(String[] args) throws IOException
>     {
>         Directory directory = create_index();
> 
>         for (int i = 1; i < 100; i++) {
>             System.err.println("loop " + i + ", index version: " + IndexReader.getCurrentVersion(directory));
>             search_index(directory);
>             add_to_index(directory, i);
>         }
>     }
> 
>     private static void add_to_index(Directory directory, int i) throws IOException
>     {
>         IndexWriter writer = new IndexWriter(directory, new StandardAnalyzer(), false);
> 
>         SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd");
>         Document doc = new Document();
> 
>         doc.add(Field.Keyword("date", df.format(new Date(System.currentTimeMillis()))));
>         doc.add(Field.Keyword("id", "CD" + String.valueOf(i)));
>         doc.add(Field.Text("text", "Tohle neni text " + i));
>         writer.addDocument(doc);
> 
>         System.err.println("index size: " + writer.docCount());
>         writer.close();
>     }
> 
> 	...
> 
> -----Original Message-----
> From: John Moylan [mailto:johnm@rte.ie]
> Sent: Monday, September 13, 2004 3:25 PM
> To: Lucene Users List
> Subject: Re: OutOfMemory example
> 
> 
> You should reuse your old index (as eg an application variable) unless 
> it has changed - use getCurrentVersion to check the index for updates. 
> This has come up before.
> 
> John
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: lucene-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: lucene-user-help@jakarta.apache.org
> 

******************************************************************************
The information in this e-mail is confidential and may be legally privileged.
It is intended solely for the addressee. Access to this e-mail by anyone else
is unauthorised. If you are not the intended recipient, any disclosure,
copying, distribution, or any action taken or omitted to be taken in reliance
on it, is prohibited and may be unlawful.
Please note that emails to, from and within RT may be subject to the Freedom
of Information Act 1997 and may be liable to disclosure.
******************************************************************************

---------------------------------------------------------------------
To unsubscribe, e-mail: lucene-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: lucene-user-help@jakarta.apache.org


Mime
View raw message