Closing the directory seems a bit strange, why are you doing that
(other than it is a public method), especially since you say you are
keeping the IndexSearcher around? Also, you probably shouldn't open a
new searcher every time. Are your queries on different directories
every time?
What testing have you done to date that lead you to believe this
section of code is the cause of the problem?
-Grant
On Sep 2, 2008, at 3:53 PM, Andy33 wrote:
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: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
--------------------------
Grant Ingersoll
http://www.lucidimagination.com
Lucene Helpful Hints:
http://wiki.apache.org/lucene-java/BasicsOfPerformance
http://wiki.apache.org/lucene-java/LuceneFAQ
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]