I've been using search service for some time now, mosty in classic jira plugins without problems.
Recently I was doing some upgrade of old custom tabs, which were basically jsp pages with lots of scriplets, that called some java classes to show issues. Issues were searched by classical sql statement and it was very slow, so I decided to remove it and replace with search service (with JQL). Now it turns out, that calling searchService.search ends up with memory leak (thousands of char[] and org.apache.lucene.document.Field left behind, and after few searches jira blows up with OutOfMemory Java heap space or GC overhead limit exceeded errors.
My code is as follows:
String query = "PROJECT IN (10010,10011,10020,10021,10062,10070,10120) and fixversion != 'Cancelled Features' AND fixversion IS NOT NULL ";
//String query = "PROJECT = 10010";
SearchService service = ComponentManager.getInstance().getSearchService();
final SearchService.ParseResult parseResult = service.parseQuery(
jiraUser, query);
if (parseResult.isValid()) {
try {
final SearchResults results = service.search(jiraUser,
parseResult.getQuery(),
PagerFilter.getUnlimitedFilter());
issues = results.getIssues();
} catch (SearchException e) {
SQL.error("Error running search", e);
}
....
Any ideas what might be wrong?
Community moderators have prevented the ability to post new answers.
No,
I call it from a jsp page, something like
<% List issues = mybean.getIssues() %>
<table>
<% for(int i=0; i<issues.size();i++%>
<tr><td><%= issues.get(i).getKey()%></td></tr>
...
The search gives me about 20k issues. I attached a profiler to my jira, and when I run the jql in issue navigator everything works fine, if I display the page with the code I can see that lots of data (char[] and org.apache.lucene.document.Field are not cleaned up after the page has loaded)
I wonder if this may be related to this bug
I even tried to add some cleanup code in finally block
finally{
DefaultIndexManager.flushThreadLocalSearchers();
service = null;
}
but it did not help
The code looks fine. Are you calling it in a loop or something? Also how many issues do you have and what is the allocated memory?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.