lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Marc Sturlese <>
Subject memory leak getting docs
Date Wed, 05 Nov 2008 20:11:25 GMT

Hey there, I have posted about this problem before but I think I didn't
explain mysql very well.
I'll try to explain my problem inside the context:
I get ids from a database and I look for the documents in an index that
correspon to each id. There is just one match for every id. One I have the
docuement, I have to modify some fields. What I do is to create a new doc,
copy the fields of the old doc doing the modifications, delete the old doc
from the index and add the new.
I have to do it for about 5.000 documents.
My problem is that when I ejecute the app it starts increasing the memory
use until 700Mb or even more.
I have realized that the memory leak apperars when getting the docuements.
I leave here the piece of code I use to do that... any advice would be
really helpful coz it's driving me mad.

private Document getDocumentData(String id) {
        IndexSearcher searcher = null ;
        IndexReader reader = null;
        Document doc = null ;
        TermDocs td = null;
        try {
            searcher = new IndexSearcher(path_my_index) ;
            td=reader.termDocs(new Term(GlobalFields.ID,id)) ;
                doc = reader.document(td.doc()) ;  
            if(td != null)
                td.close() ;
        } catch (Exception ex) {
            logger.error("Troubles geting data: " + ex.getMessage()) ;
            logger.error("Stack: " + ErrorStack.getError(ex)) ;
        } finally {
           if(searcher != null) {
                try {
                    reader.close() ;
                    searcher.close() ;
                    reader = null ;
                    searcher = null ;
                } catch(Exception e){} ;
                    reader = null ;
                    searcher = null ;
        return doc ;

This functions is called for every doc which I have to get the information
PD: If I call manually the garbage collector at the end of the function the
memory leak never apears... but the app runs really slow!!
Thanks in advanced


View this message in context:
Sent from the Lucene - Java Users mailing list archive at

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message