lucene-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Aleksey Serba" <ase...@gmail.com>
Subject Custom sorting - memory leaks
Date Fri, 18 Aug 2006 09:01:45 GMT
Hi!

Could you please read the following discussion in java-user mail list
- http://www.gossamer-threads.com/lists/lucene/java-user/35352

You can reproduce OutOfMemory easily. I've attach test files - this is
altered DistanceSortingTest example from LIA book. Also you can
profile it and see caching of distances arrays.

Probably, you could add some caching option to custom sorting feature.

I've modify FieldSortedHitQueue.java to not cache CUSTOM sorting as
"works for me" solution.

-Aleksey

===== FieldSortedHitQueue.java patch =====
@@ -182,7 +182,9 @@
   throws IOException {
     if (type == SortField.DOC) return ScoreDocComparator.INDEXORDER;
     if (type == SortField.SCORE) return ScoreDocComparator.RELEVANCE;
-    ScoreDocComparator comparator = lookup (reader, fieldname, type,
locale, factory);
+    ScoreDocComparator comparator = null;
+    if( type != SortField.CUSTOM )
+       comparator = lookup (reader, fieldname, type, locale, factory);
     if (comparator == null) {
       switch (type) {
         case SortField.AUTO:
@@ -204,7 +206,8 @@
         default:
           throw new RuntimeException ("unknown field type: "+type);
       }
-      store (reader, fieldname, type, locale, factory, comparator);
+      if( type != SortField.CUSTOM )
+         store (reader, fieldname, type, locale, factory, comparator);
     }
     return comparator;
   }
===== FieldSortedHitQueue.java patch =====


Mime
View raw message