Click here to Skip to main content
15,891,529 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
when I run the projects, the counts of the threads will increase ,and after about 30 minutes the counts of the threads will be to 1000+, and cause the OutOfMemory Exception.
I have tried to use the ThreadPool.SetMaxThreads which will limited the max counts of the threads, while I don't know which numbers of the max threads would be suitable. Does it be relational with the cores of the computers?
Posted
Comments
Sergey Alexandrovich Kryukov 17-Dec-14 0:18am    
Excuse me, what do you think would be the use of so many threads? It could seriously compromise your performance.
—SA
BillWoodruff 17-Dec-14 0:20am    
What in your code creates so many threads ?

1 solution

OutOfMemory exceptions occur mostly on 32bit systems when you reach more than ~2gb memory usage.

1) Try running on a 64bit system.
2) Seriously rethink how you are doing things when you have thread running for 30 minutes without reuse.
3) Try using Tasks instead of threads since they are lighter on resources.
 
Share this answer
 

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