Categories connection-leaks connection-pooling performancecounter sql-server

How to detect SqlServer connection leaks in a applications?

I’m currently doing some GUI testing on a 2.0 application.
The RDBMS is SQL Server 2005. The host is Win Server 2003 / IIS 6.0.

I do not have the source code of the application because it was programmed by an external company who’s not releasing the code.

I’ve noticed that the application performs well when I restart IIS but after some testing, after I have opened and closed my browser for a couple of hours, the application starts to get slower and slower. I was wondering if this behaviour was due to a bad closing connection practice from the programmers : I’m suspecting an open connection leak on the database here.

I guess the .Net garbage collector will eventually close them but… that can take a while, no?

I’ve got SQL Server Management Studio and I do notice from the activity monitor that there are quite a few connections opened on the database.

From all that’s being said above, here are some questions related to the main question :

  1. Is there any way to know in SQL
    Server 2005 if connections are
    open because they’re waiting to be
    used in a connection pool or if
    they’re open because they are used by an

  2. Does somone know of good
    online/paper resources where I could
    learn how to use performance
    counters or some other kind of tools
    to help track down these kind of

  3. If performance counters are the best
    solution, what are the variables that I
    should watch?

You can always check the connection strings from web.config (mainly if they have connection pooling activated, if they have any connection limits enabled).

Also, if you are using IIS 6, you could set your web application to use a separate Application pool, and set other option for the recycling of the memory and processes.

About the performance counters, you could check how long the garbage collector is running,
how much memory the application is using, etc.

If you have access to sql server, you could monitor the connections made from your application (there are performance counters defined for every installed instance of SQL Server).

There were some articles in MSDN Magazine. Also you could use the SOS Debugging library to attach to the application’s process and check it manually.

And, if you don’t have the source code, try to use Reflector to get the sources of the application (they would be very usefull for debugging)

@Later edit:You could check this question here on too