Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

C# Handles Count

Tags:

c#

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();
}

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?

Thanks.

like image 835
Chris MC Avatar asked Mar 10 '15 10:03

Chris MC


1 Answers

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

like image 99
tia Avatar answered Sep 22 '22 05:09

tia