From 52a4534f7fe9e7b044a54f5a794391b54a1edb94 Mon Sep 17 00:00:00 2001 From: John Hurliman Date: Fri, 23 Oct 2009 13:45:18 -0700 Subject: * Change the way Util.FireAndForget() calls SmartThreadPool to avoid using a delegate (which STP appears to hold on to). This removes the slow leak I was seeing when using async_call_method=SmartThreadPool and stabilizes allocated memory for an idle OpenSim instance --- OpenSim/Framework/Util.cs | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/OpenSim/Framework/Util.cs b/OpenSim/Framework/Util.cs index b96367a..10f38ab 100644 --- a/OpenSim/Framework/Util.cs +++ b/OpenSim/Framework/Util.cs @@ -1347,7 +1347,7 @@ namespace OpenSim.Framework case FireAndForgetMethod.SmartThreadPool: if (m_ThreadPool == null) m_ThreadPool = new SmartThreadPool(2000, 15, 2); - m_ThreadPool.QueueWorkItem(delegate(object o) { callback(o); return null; }, obj); + m_ThreadPool.QueueWorkItem(SmartThreadPoolCallback, new object[] { callback, obj }); break; case FireAndForgetMethod.Thread: Thread thread = new Thread(delegate(object o) { callback(o); }); @@ -1358,6 +1358,16 @@ namespace OpenSim.Framework } } + private static object SmartThreadPoolCallback(object o) + { + object[] array = (object[])o; + WaitCallback callback = (WaitCallback)array[0]; + object obj = array[1]; + + callback(obj); + return null; + } + #endregion FireAndForget Threading Pattern } } -- cgit v1.1