From 55c1c10c0dc3f189107ab43b43988a8b8833f136 Mon Sep 17 00:00:00 2001 From: Melanie Date: Mon, 23 Jul 2012 19:26:21 +0100 Subject: [PATCH] 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. --- OpenSim/Framework/LocklessQueue.cs | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/OpenSim/Framework/LocklessQueue.cs b/OpenSim/Framework/LocklessQueue.cs index dd3d2016d1..84f887cc4d 100644 --- a/OpenSim/Framework/LocklessQueue.cs +++ b/OpenSim/Framework/LocklessQueue.cs @@ -99,8 +99,13 @@ namespace OpenSim.Framework } else { - item = oldHeadNext.Item; + item = oldHeadNext.Item; 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() { + // ugly + T item; + while(count > 0) + Dequeue(out item); Init(); }