Ok. I was able to conclude that the I am getting OOME due to my usage of HTML
Parser to get the HTML title and HTML text. I display 10 results per page
and therefore end up calling the org.apache.lucene.demo.html.HTMLParser 10
times.
I modified my code to store the title and html summary in the index itself
and found out that the OOME problem is gone.
I tested this with 256MB heap size.
Thank you all for your valuable advice and help.
Chetan Shah wrote:
>
> I am initiating a simple search and after profiling the my application
> using NetBeans. I see a constant heap consumption and eventually a server
> (tomcat) crash due to "out of memory" error. The thread count also keeps
> on increasing and most of the threads in "wait" state.
>
> Please let me know what am I doing wrong here so that I can avoid server
> crash. I am using Lucene 2.4.0.
>
>
> IndexSearcher indexSearcher =
> IndexSearcherFactory.getInstance().getIndexSearcher();
>
>
> //Create the query and search
> QueryParser queryParser = new QueryParser("contents",
> new
> StandardAnalyzer());
> Query query = queryParser.parse(searchCriteria);
>
>
> TermsFilter categoryFilter = null;
>
> // Create the filter if it is needed.
> if (filter != null) {
> Term aTerm = new
> Term(Constants.WATCH_LIST_TYPE_TERM);
> categoryFilter = new TermsFilter();
> for (int i = 0; i < filter.length; i++) {
>
> aTerm = aTerm.createTerm(filter[i]);
> categoryFilter.addTerm(aTerm);
> }
> }
>
> // Create sort criteria
> SortField [] sortFields = new SortField[2];
> SortField watchList = new
> SortField(Constants.WATCH_LIST_TYPE_TERM,
> SortField.STRING);
> SortField score = SortField.FIELD_SCORE;
> if (sortByWatchList) {
> sortFields[0] = watchList;
> sortFields[1] = score;
> } else {
> sortFields[1] = watchList;
> sortFields[0] = score;
>
> }
> Sort sort = new Sort(sortFields);
>
> // Collect results
> TopDocs topDocs = indexSearcher.search(query,
> categoryFilter,
> Constants.MAX_HITS, sort);
> ScoreDoc scoreDoc[] = topDocs.scoreDocs;
> int numDocs = scoreDoc.length;
> if (numDocs > 0) results = scoreDoc;
>
>
--
View this message in context:
http://www.nabble.com/Memory-Leak--tp22663917p22721161.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]