Are all the database connections in this application being closed when they should be? This is a question I asked myself today and it reminded me of a Windows XP feature I learned about in class a few years ago. If you go to Windows’ “Administrative Tools”, which can be accessed through the “Control Panel”, there is an application titled “Performance”. Double-clicking on this application opens a window with a real time graph. If you click on the “+” icon above the graph you’ll get another window with a drop-down that allows you to select from a long list of performance counter categories. I selected the “SQLServer: General Statistics” category and then was given the opportunity to add “Logins/sec”, “Logouts/sec” and “User Connections” to the graph. After selecting “User Connections” I was able to see that the application I was working with was not implicitly closing all database connections that it was opening.
As I mentioned, there is a long list of performance counter categories to select from, including “Web Service” which can be useful if you’re working with IIS. If you’re developing in .NET you can even create your own custom performance counters, for instance you might want to create a “Number of people named Bob that log-in to your website” performance counter.