Click here to Skip to main content
16,014,677 members
Please Sign up or sign in to vote.
2.00/5 (1 vote)
See more:
I have been using the C# smart thread pool to do some work but found the current smart thread pool release DOES NOT anything about the removed "idle threads". This may or may not cause smart thread pool memory leaks.

In the smartthreadpool.ProcessQueueItem() method there are several times the method calls InforComleted() method when a idle thread(s) is timed out. But the InformCompleted() just removes the thread from the dictionary and didn't the delete these threads:
C#
private void InformCompleted()
{
   if(_workerThreads.Contains(Thread.CurrentThread))
   {
      _workerThreads.Remove(Thread.CurrentThread);
   }
}

I'm wondering if there is anyone out there already solved this problem and test it out.

Thank you very much.

Best regards,
CodeBeetle123
Posted
Updated 13-May-13 10:33am
v2
Comments
Sergey Alexandrovich Kryukov 13-May-13 16:41pm    
Why? This is not how Thread Pool is used.
—SA

1 solution

Normally, you DON'T remove threads from the pool. They sit there idle, waiting for work to do so you don't incur the rather large overhead of spinning a new thread up!

If you've got questions about a particular library, you contact the author of that library. Just because you saw it in an article here does NOT mean that everyone around here knows exactly what you're talking about and has used every bit of code in every article.
 
Share this answer
 
Comments
CodeBeetle123 14-May-13 13:14pm    
Thanks for the comments. Actually the author of this librsry makes it configurable for deleting idle thread or not to.

Here I just bring it to attention there is an issue in the library if someone decides to delete the "TIMEED OUT" idle threads.

I posted the same question in the smart thread pool discussion section hoping the author will response.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900