lucenenet-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Vova Tymchenko <halle...@yahoo.com>
Subject Possible leaks in SegmentReader and TermInfosReader
Date Thu, 29 Mar 2007 09:46:31 GMT
Hello everybody,

I'm using Lucene.Net with my own implementation of Directory which stores the files in the
SQL database.
Additionally, it maintains the reference count for the locks created in the directory. One
thing I noticed is
that there are locks left behind sometimes. Eventually, I tracked the problem down to SegmentReader.

The trouble that I see with SegmentReader (and TermInfosReader as well) is that it stores
references
to TermVectorsReader in ThreadLocalStore when GetTermVectorsReader is called, but .Close method
fails
to close and clean up that reference.

The change that I've implemented in my local copy of Lucene (and which seems to work) is like
this - I added
the following code to the beginning of DoClose in SegmentReader:

            TermVectorsReader tvReader = (TermVectorsReader) System.Threading.Thread.GetData(termVectorsLocal);

            if (tvReader != null)
            {
                tvReader.Close();
                System.Threading.Thread.SetData(termVectorsLocal, null);
            }

The following change has been done to TermInfosReader:

            SegmentTermEnum termEnum = (SegmentTermEnum) System.Threading.Thread.GetData(enumerators);

            if (termEnum != null)
            {
                termEnum.Close();
                System.Threading.Thread.SetData(enumerators, null);
            }

Regards,
Volodymyr.


 
____________________________________________________________________________________
Now that's room service!  Choose from over 150,000 hotels
in 45,000 destinations on Yahoo! Travel to find your fit.
http://farechase.yahoo.com/promo-generic-14795097

Mime
View raw message