You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@lucenenet.apache.org by "Digy (JIRA)" <ji...@apache.org> on 2008/06/26 18:35:45 UTC
[jira] Commented: (LUCENENET-106) Lucene.NET (Revision: 603121) is
leaking memory
[ https://issues.apache.org/jira/browse/LUCENENET-106?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12608489#action_12608489 ]
Digy commented on LUCENENET-106:
--------------------------------
Lucene.Net 2.3.1 also suffers from the same bug.
Below are the results of memory usage of the sample program
Original Lucene.Net 2.3.1
01) MemUsage: 34828 KB
02) MemUsage: 36352 KB
03) MemUsage: 39452 KB
04) MemUsage: 41768 KB
05) MemUsage: 47420 KB
06) MemUsage: 49720 KB
07) MemUsage: 52904 KB
08) MemUsage: 56712 KB
09) MemUsage: 61520 KB
10) MemUsage: 64988 KB
Patch applied to FieldCacheImpl.cs
01) MemUsage: 34644 KB
02) MemUsage: 35564 KB
03) MemUsage: 38532 KB
04) MemUsage: 41960 KB
05) MemUsage: 47144 KB
06) MemUsage: 49996 KB
07) MemUsage: 52232 KB
08) MemUsage: 54736 KB
09) MemUsage: 55276 KB
10) MemUsage: 61544 KB
Patch applied to FieldCacheImpl.cs , CachingWrapperFilter.cs , CachingSpanFilter.cs
01) MemUsage: 32764 KB
02) MemUsage: 32760 KB
03) MemUsage: 31404 KB
04) MemUsage: 31404 KB
05) MemUsage: 31404 KB
06) MemUsage: 31408 KB
07) MemUsage: 31408 KB
08) MemUsage: 31408 KB
09) MemUsage: 31408 KB
10) MemUsage: 31408 KB
{code}
//SAMPLE CODE
namespace WindowsApplication1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
CreateTestIndex();
}
Lucene.Net.Documents.Document GetDoc()
{
Lucene.Net.Documents.Document doc = new Lucene.Net.Documents.Document();
Lucene.Net.Documents.Field f1 = new Lucene.Net.Documents.Field("field1", "value1 value11", Lucene.Net.Documents.Field.Store.YES, Lucene.Net.Documents.Field.Index.TOKENIZED);
Lucene.Net.Documents.Field f2 = new Lucene.Net.Documents.Field("field2", "value2 value22", Lucene.Net.Documents.Field.Store.YES, Lucene.Net.Documents.Field.Index.UN_TOKENIZED);
doc.Add(f1);
doc.Add(f2);
return doc;
}
void CreateTestIndex()
{
Lucene.Net.Index.IndexWriter wr = new Lucene.Net.Index.IndexWriter("blabla", new Lucene.Net.Analysis.Standard.StandardAnalyzer(), true);
for (int i = 0; i < 500; i++)
{
wr.AddDocument(GetDoc());
}
wr.Close();
}
int Count = 0;
public void TestMemoryLeakage()
{
for (int i = 0; i < 250; i++)
{
Lucene.Net.Search.IndexSearcher s = new Lucene.Net.Search.IndexSearcher("blabla");
Lucene.Net.QueryParsers.QueryParser qp = new Lucene.Net.QueryParsers.QueryParser("field1", new Lucene.Net.Analysis.Standard.StandardAnalyzer());
Lucene.Net.Search.Query q = qp.Parse("value1");
Lucene.Net.Search.Sort sort = new Lucene.Net.Search.Sort("field2");
Lucene.Net.Search.Hits hits = s.Search(q, null, sort);
s.Close();
}
GC.Collect();
Count++;
richTextBox1.AppendText(Count.ToString("00") + ") MemUsage: " + (System.Diagnostics.Process.GetCurrentProcess().WorkingSet / 1024).ToString() + " KB\n");
}
private void button2_Click(object sender, EventArgs e)
{
for (int i = 0; i < 10; i++)
{
TestMemoryLeakage();
Application.DoEvents();
}
}
}
}
{code}
> Lucene.NET (Revision: 603121) is leaking memory
> -----------------------------------------------
>
> Key: LUCENENET-106
> URL: https://issues.apache.org/jira/browse/LUCENENET-106
> Project: Lucene.Net
> Issue Type: Bug
> Environment: .NET 2.0
> Reporter: Anton K.
> Priority: Critical
> Attachments: DIGY-FieldCacheImpl.patch, Digy.rar, luceneSrc_memUsage.patch, WeakHashTable+FieldCacheImpl.rar, WeakReferences.rar
>
>
> readerCache Hashtable field (see FieldCacheImpl.cs) never releases some hash items that have closed IndexReader object as a key. So a lot of Term instances are never released.
> Java version of Lucene uses WeakHashMap and therefore doesn't have this problem.
> This bug can be reproduced only when Sort functionality used during search.
> See following link for additional information.
> http://www.gossamer-threads.com/lists/lucene/java-user/55681
> Steps to reproduce:
> 1)Create index
> 2) Modify index by IndexWiter; Close IndexWriter
> 3) Use IndexSearcher for searching with Sort; Close InexSearcher
> 4) Go to step 2
> You'll get OutOfMemoryException after some time of running this algorithm.
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.