Use JetBrains to track down SqlConnection leak?

My .net IIS web app, eventually runs into an error when attempting to obtain a sqlconnection. 

System.InvalidOperationException, mscorlib
Message: Timeout expired. The timeout period elapsed prior to obtaining a connection from the pool. This may have occurred because all pooled connections were in use and max pool size was reached.
Source: System.Data
StackTrace: at System.Data.ProviderBase.DbConnectionFactory.TryGetConnection(DbConnection owningConnection, TaskCompletionSource`1 retry, DbConnectionOptions userOptions, DbConnectionInternal oldConnection, DbConnectionInternal& connection)
at System.Data.ProviderBase.DbConnectionInternal.TryOpenConnectionInternal(DbConnection outerConnection, DbConnectionFactory connectionFactory, TaskCompletionSource`1 retry, DbConnectionOptions userOptions)
at System.Data.SqlClient.SqlConnection.TryOpenInner(TaskCompletionSource`1 retry)
at System.Data.SqlClient.SqlConnection.TryOpen(TaskCompletionSource`1 retry)
at System.Data.SqlClient.SqlConnection.Open()


I suspect this indicates that somewhere in the code we are leaking a sqlconnection (not closing/disposing a sqlconnection).

Is there a good way to track do where in the code this is happening using either dotTrace or dotMemory?



1 comment
Comment actions Permalink

Hi Scott,


You can use Timeline profiling mode in dotTrace to track SQL connections:

Please let me know if you have any additional questions.


Please sign in to leave a comment.