* 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

0.6.8-post-fixes
John Hurliman 2009-10-23 13:45:18 -07:00
parent a41cd1d069
commit 52a4534f7f
1 changed files with 11 additions and 1 deletions

View File

@ -1347,7 +1347,7 @@ namespace OpenSim.Framework
case FireAndForgetMethod.SmartThreadPool: case FireAndForgetMethod.SmartThreadPool:
if (m_ThreadPool == null) if (m_ThreadPool == null)
m_ThreadPool = new SmartThreadPool(2000, 15, 2); 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; break;
case FireAndForgetMethod.Thread: case FireAndForgetMethod.Thread:
Thread thread = new Thread(delegate(object o) { callback(o); }); 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 #endregion FireAndForget Threading Pattern
} }
} }