[pylucene-dev] memory leak passing sequence of string

Aaron Lav asl2 at pobox.com
Fri Oct 31 11:21:55 PDT 2008


I noticed this with StopFilter: there seems to be a missing
DeleteLocalRef in JArray's specialization for strings.  I'm attaching
a test case and a patch.  (The other specializations all look OK, since
they're scalar types not requiring allocation.)

   Aaron Lav (asl2 at pobox.com)


-------------- next part --------------
import lucene

if __name__ == '__main__':
    env = lucene.initVM(classpath=lucene.CLASSPATH)
    stop_set = ['the', 'and', 's']
    reader = lucene.StringReader('foo')
    while 1:
        result = lucene.StandardTokenizer(reader)
        result = lucene.StopFilter(result, stop_set)

-------------- next part --------------
Index: jcc/sources/JArray.h
===================================================================
--- jcc/sources/JArray.h	(revision 475)
+++ jcc/sources/JArray.h	(working copy)
@@ -267,6 +267,7 @@
                 break;
 
             env->setObjectArrayElement((jobjectArray) this$, i, str);
+            env->get_vm_env()->DeleteLocalRef(str);
         }
     }
 


More information about the pylucene-dev mailing list