1 From: Joe Shaw <joeshaw@novell.com>
3 Lucene uses thread-local storage for caching some data in a threadsafe way.
4 Mono up through 1.1.13.4 leaks all data set using Thread.SetData(), and this
5 accounts for huge memory spikes in Beagle in the file system backend on
6 inotify events and any time a query is run. Instead we'll just declare the
9 Index: Index/SegmentReader.cs
10 ===================================================================
11 RCS file: /cvs/gnome/beagle/beagled/Lucene.Net/Index/SegmentReader.cs,v
12 retrieving revision 1.3
13 diff -u -p -r1.3 SegmentReader.cs
14 --- Index/SegmentReader.cs 6 Oct 2005 19:29:55 -0000 1.3
15 +++ Index/SegmentReader.cs 3 Apr 2006 17:09:07 -0000
16 @@ -36,8 +36,10 @@ namespace Lucene.Net.Index
17 private FieldsReader fieldsReader;
19 internal TermInfosReader tis;
20 - internal TermVectorsReader termVectorsReaderOrig = null;
21 - internal System.LocalDataStoreSlot termVectorsLocal = System.Threading.Thread.AllocateDataSlot();
22 + internal TermVectorsReader termVectorsReaderOrig = null;
25 + private TermVectorsReader tvReader;
27 internal BitVector deletedDocs = null;
28 private bool deletedDocsDirty = false;
29 @@ -172,19 +174,6 @@ namespace Lucene.Net.Index
35 - // patch for pre-1.4.2 JVMs, whose ThreadLocals leak
38 - System.Threading.Thread.SetData(termVectorsLocal, null); // {{Aroush-1.9}} is this required for .NET ?!
40 - catch (Exception ex)
42 - // System.Console.WriteLine(ex.Message);
46 protected internal override void DoCommit()
49 @@ -609,11 +598,9 @@ namespace Lucene.Net.Index
51 private TermVectorsReader GetTermVectorsReader()
53 - TermVectorsReader tvReader = (TermVectorsReader) System.Threading.Thread.GetData(termVectorsLocal);
56 tvReader = (TermVectorsReader) termVectorsReaderOrig.Clone();
57 - System.Threading.Thread.SetData(termVectorsLocal, tvReader);
61 Index: Index/TermInfosReader.cs
62 ===================================================================
63 RCS file: /cvs/gnome/beagle/beagled/Lucene.Net/Index/TermInfosReader.cs,v
64 retrieving revision 1.4
65 diff -u -p -r1.4 TermInfosReader.cs
66 --- Index/TermInfosReader.cs 6 Oct 2005 19:29:55 -0000 1.4
67 +++ Index/TermInfosReader.cs 3 Apr 2006 17:09:07 -0000
68 @@ -28,8 +28,10 @@ namespace Lucene.Net.Index
69 private Directory directory;
70 private System.String segment;
71 private FieldInfos fieldInfos;
73 - private System.LocalDataStoreSlot enumerators = System.Threading.Thread.AllocateDataSlot();
76 + private SegmentTermEnum termEnum;
78 private SegmentTermEnum origEnum;
81 @@ -50,20 +52,7 @@ namespace Lucene.Net.Index
83 indexEnum = new SegmentTermEnum(directory.OpenInput(segment + ".tii"), fieldInfos, true);
88 - // patch for pre-1.4.2 JVMs, whose ThreadLocals leak
91 - System.Threading.Thread.SetData(enumerators, null); // {{Aroush-1.9}} is this required for .NET ?!
93 - catch (Exception ex)
95 - System.Console.WriteLine(ex.Message);
100 public int GetSkipInterval()
102 return origEnum.skipInterval;
103 @@ -85,11 +74,9 @@ namespace Lucene.Net.Index
105 private SegmentTermEnum GetEnum()
107 - SegmentTermEnum termEnum = (SegmentTermEnum) System.Threading.Thread.GetData(enumerators);
108 if (termEnum == null)
111 - System.Threading.Thread.SetData(enumerators, termEnum);