[pylucene-dev] memory leak status

anurag uniyal anuraguniyal at yahoo.com
Fri Jan 11 03:25:43 PST 2008


Skipped content of type multipart/alternative-------------- next part --------------
import os
import sys
import threading

import lucene
lucene.initVM(lucene.CLASSPATH, maxheap='5m')


class MyDocument(lucene.Document):
    indexType = lucene.Field.Index.UN_TOKENIZED # TOKENIZED fails
    def __init__(self):
        lucene.Document.__init__(self)

        self.add(lucene.Field("body", "what a body", lucene.Field.Store.YES, MyDocument.indexType))

class DocThread(threading.Thread):
    def __init__(self, writer):
        threading.Thread.__init__(self)
        self.writer = writer
        self.error = None
        
    def run(self):
        try:
            lucene.getVMEnv().attachCurrentThread()
            self.writer.addDocument(MyDocument())
        except Exception,e:
            self.error = e

def main():
    _store = lucene.FSDirectory.getDirectory("/tmp/index/", True)
    _writer = lucene.IndexWriter(_store, lucene.StandardAnalyzer(), True)

    for i in xrange(500):
        if i%100 == 0: print i

        t = DocThread(_writer)
        t.start()
        t.join()

        if t.error:
            print t.error
            break

        
main()
print "lucene.Field.Index.UN_TOKENIZED works but TOKENIZED fails..."
MyDocument.indexType = lucene.Field.Index.TOKENIZED
main()


More information about the pylucene-dev mailing list