[ 
https://issues.apache.org/jira/browse/LUCENENET-106?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12665560#action_12665560
 ] 

TJ Kolev commented on LUCENENET-106:
------------------------------------

Wow guys, lots of action, good work.

On Digy's last comment, how about the following enumerator. Tests I have pass. 
But I am not certain it totally lives up to the expected IDictionaryEnumerator 
semantics. The enumerator relies on the Keys from the WeakHashTable to get the 
right elements. 

tjk :)

{noformat}

                class WeakDictionaryEnumerator : IDictionaryEnumerator
                {
                        private ArrayList _entries = null;
                        private int _currentNdx = -1;

                        public WeakDictionaryEnumerator(WeakHashTable tbl)
                        {
                                _entries = new ArrayList(tbl.Keys.Count);
                                foreach(object key in tbl.Keys)
                                {
                                        _entries.Add(new DictionaryEntry(key, 
tbl[key]));
                                }
                        }

                        public object Key
                        {
                                get { return Entry.Key; }
                        }

                        public object Value
                        {
                                get { return Entry.Value; }
                        }

                        public DictionaryEntry Entry
                        {
                                get { return (DictionaryEntry) 
_entries[_currentNdx]; }
                        }

                        public bool MoveNext()
                        {
                                if (_currentNdx + 1 >= _entries.Count)
                                        return false;
                                _currentNdx++;
                                return true;
                        }

                        public void Reset()
                        {
                                _currentNdx = -1;
                        }

                        public object Current
                        {
                                get { return Entry; }
                        }
                }

{noformat} 

In WeakHashTable:

{noformat} 
        public override IDictionaryEnumerator GetEnumerator()
        {
                        return new WeakDictionaryEnumerator(this);
        }
{noformat} 

> 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.
>            Assignee: Digy
>            Priority: Critical
>         Attachments: DIGY-FieldCacheImpl.patch, Digy.rar, 
> luceneSrc_memUsage.patch, Paches for v2.3.1.rar, WeakHashTable v2.patch, 
> WeakHashTable v2.patch, WeakHashTable+FieldCacheImpl.rar, 
> WeakHashTable_ep.zip, WeakHashTable_ep_v2.zip, WeakHashTable_tj.zip, 
> 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.

Reply via email to