Committing Avination's memleak fix-a-thon, installment #2

Ensure items coming off the lockless queue are released. Also ensure this
is done when the queue is cleared.
0.7.3-extended
Melanie 2012-07-23 19:26:21 +01:00 committed by Justin Clark-Casey (justincc)
parent 91ae1908fe
commit 2d66fcd4cd
1 changed files with 10 additions and 1 deletions

View File

@ -101,6 +101,11 @@ namespace OpenSim.Framework
{ {
item = oldHeadNext.Item; item = oldHeadNext.Item;
haveAdvancedHead = CAS(ref head, oldHead, oldHeadNext); haveAdvancedHead = CAS(ref head, oldHead, oldHeadNext);
if (haveAdvancedHead)
{
oldHeadNext.Item = default(T);
oldHead.Next = null;
}
} }
} }
} }
@ -111,6 +116,10 @@ namespace OpenSim.Framework
public void Clear() public void Clear()
{ {
// ugly
T item;
while(count > 0)
Dequeue(out item);
Init(); Init();
} }