C#处理计数 [英] C# Handles Count
问题描述
我一直在研究我的一个应用程序可能发生内存泄漏的可能性,因此开始研究一些非常基本的代码示例.最后,剩下的一个我的句柄数量(> 3000)开始大大增加.这是一个非常简单的控制台应用程序,其代码如下:
I was looking into the possibility that one of my applications might have a memory leak, so started playing about with some very basic code samples. One I ended up with, when left over time, started to increase greatly in terms of the number of Handles (>3000). It is a very simple Console application with the code as follows:
public static void Main(string[] args)
{
using (SqlConnection sqlConnection = new SqlConnection())
{
}
Console.ReadLine();
}
排除SqlConnection调用将删除任何Handle增加,因此我假设它与连接池有关.但是,由于在基本等待输入之前只运行一次,为什么Handle计数会不断增加?
Taking out the SqlConnection call removes any Handle increase, so I am assuming it has something to do with the connection pool. But as this only runs once before basically going into a wait for input, why would the Handle count keep increasing?
谢谢.
推荐答案
如果您是在.NET 4.0上运行它,则可能是这种情况
If you are running it on .NET 4.0, this might be the case
https://connect.microsoft.com/VisualStudio/feedback/details/691725/sqlconnection-handle-leak-net-4-0
这篇关于C#处理计数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!