Hey,

Looks like there are some memory leaks in JArray_string, when iterating or accessing its items. I've seen it reproduce with 2.4.1 on linux and osx. Attached is a test case to demonstrate it using Document.getValues, and a potential patch.

"""
Memory leak in string array, as returned by Document.getValues.
Low maxheap set to introduce error quickly.
"""

import itertools
import lucene

if __name__ == '__main__':
    lucene.initVM(lucene.CLASSPATH, maxheap='10m')
    
    writer = lucene.IndexWriter(lucene.RAMDirectory(), lucene.StandardAnalyzer())
    doc = lucene.Document()
    for value in ('one', 'two'):
        doc.add(lucene.Field('test', value, lucene.Field.Store.YES, lucene.Field.Index.NO))
    writer.addDocument(doc)
    writer.commit()
    
    reader = lucene.IndexReader.open(writer.directory)
    for i in itertools.count():
        values = reader.document(0).getValues('test')
        # comment out loop through values, and the leak disappears
        for value in values:
            pass
        if not i % 10000:
            print i

Reply via email to