System.Threading.ThreadPool.SetMaxThreads的默认值 [英] Default values for System.Threading.ThreadPool.SetMaxThreads

查看:189
本文介绍了System.Threading.ThreadPool.SetMaxThreads的默认值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

假设,我没有通过调用该函数来显式设置任何值:

Suppose, I don't set any values explicitly by calling the function:

System.Threading.ThreadPool.SetMaxThreads

默认值是什么?

推荐答案

它取决于.NET Framework版本,已在2.0、3.0和4.0中进行了更改。在2.0中,它是内核数的50倍。在3.0(aka 2.0 SP1)中,它是内核数的250倍,而4.0使它根据位和操作系统资源而动态。如果我没记错的话,最大I / O完成线程数总是1000。

It depends on the .NET framework version, changed in 2.0, 3.0 and 4.0. In 2.0 it was 50 times the number of cores. In 3.0 (aka 2.0 SP1) it was 250 times the number of cores, 4.0 made it dynamic depending on bitness and OS resources. Max I/O completion threads was always 1000 if I remember correctly.

通常,它太高了,程序永远不要关闭。在32位计算机上,当所有这些线程以一兆字节的堆栈占用可用的虚拟内存时,程序很可能首先用OOM轰炸。通常,只有在有很多TP线程请求并且正在运行的请求分钟未完成时,它才会失控。 TP线程的理想状态是时间不超过半秒。

In general, it is insanely high and a program should never get close. On a 32-bit machine, the program is pretty likely to bomb with OOM first when all of those threads consume the available virtual memory with their one megabyte stacks. In general, it can only get out of hand when there are a lot of TP thread requests and the running ones are not completing for minutes. The ideal for a TP thread is to not take more than half a second.

Debug> Windows> Threads调试器窗口会告诉您令人不快的事实。并很好地暗示了为什么这些TP线程未完成,您可以看到它们的调用堆栈。

The Debug > Windows > Threads debugger window tells the unpleasant truth. And gives a very good hint why these TP threads are not completing, you can see their call stack.

这篇关于System.Threading.ThreadPool.SetMaxThreads的默认值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆