Why is this taking up all the memory?
-
I'm using Lucene.Net to index a DB. Getting all the records is quickly done, but when i index them, the memory just keeps going up on my application. This is how the code looks:
Private writer As Lucene.Net.Index.IndexWriter
Private Sub InsertDBIndexData(ByVal sCPR As String)
Dim doc As New Document
Dim f1 As New Field("CPR", sCPR, Field.Store.YES, Field.Index.TOKENIZED)
doc.Add(f1)
writer.AddDocument(doc)
doc = Nothing
Return
End SubPrivate Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim odConnection As OleDbConnection = New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0; Data Source=....mdb...")
odConnection.Open()
writer = New Lucene.Net.Index.IndexWriter(DBIndexLocation, New StandardAnalyzer, True)Dim odCommand As OleDbCommand = New OleDbCommand("select \* from TPers", odConnection) 'Dim odReader As OleDbDataReader = odCommand.ExecuteReader Dim odDataAdaptor As OleDbDataAdapter = New OleDbDataAdapter(odCommand) Dim odDataSet As DataSet = New DataSet odDataAdaptor.Fill(odDataSet, "TPers") Dim odDataTable As DataTable = odDataSet.Tables("TPers") For Each dr As DataRow In odDataTable.Rows InsertDBIndexData(dr("cpr").ToString) Next writer.Optimize() writer.Close() odDataAdaptor.Dispose() odConnection.Close() End Sub
i've tried to use oledbdatareader instead of oledbdataadaptor, which seems to be alot faster when indexing, but it is still takes up ALL the memory. Opening and closing the Lucene writer doesn't help either. I know i probably should be asking in some Lucene.Net forum, but i'm not sure if the problem lies in that code. And i know i've asked a question pretty much similar to this. But this isn't the same :)