lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "장용석" <need4...@gmail.com>
Subject Re: Lucene Memory Leak
Date Wed, 03 Sep 2008 01:12:31 GMT
I think when your doQuery method is run, Directory and Analyzer classes are
new create every time.
If index file's size is very large then create new Directory instance is
pressure to jvm and it takes long time for create new Directory instance.
I suggest that modify the code , Analyzer class and Directory class that
singletone pattern.
(If you can....Search Class,too)


2008/9/3, Andy33 <clever_one3@yahoo.com>:
>
>
> I have a memory leak in my lucene search code. I am able to run a few
> queries
> fine, but I eventually run out of memory. Please note that I do close and
> set to null the ivIndexSearcher object elsewhere. Here is the code I am
> using...
>
>
> private synchronized Hits doQuery(String field, String queryStr, Sort
> sortOrder, String indexDirectory) throws Exception
>    {
>        Directory directory = null;
>
>        try
>        {
>            Analyzer analyzer = new StandardAnalyzer();
>
>            directory = FSDirectory.getDirectory(indexDirectory);
>
>            //search the index
>            ivIndexSearcher = new IndexSearcher(directory);
>
>            QueryParser parser = new QueryParser(field, analyzer);
>            Query query = parser.parse(queryStr);
>            Hits results = ivIndexSearcher.search(query, sortOrder);
>
>            return results;
>        }
>        finally
>        {
>            if(null != directory)
>            {
>                directory.close();
>            }
>            directory = null;
>        }
>    }
> --
> View this message in context:
> http://www.nabble.com/Lucene-Memory-Leak-tp19276999p19276999.html
> Sent from the Lucene - Java Users mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
> For additional commands, e-mail: java-user-help@lucene.apache.org
>
>


-- 
DEV용식
http://devyongsik.tistory.com
Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message