如何检测ASP.net应用程序中的SqlServer连接泄漏? [英] How to detect SqlServer connection leaks in a ASP.net applications?

查看:111
本文介绍了如何检测ASP.net应用程序中的SqlServer连接泄漏?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前正在ASP.net 2.0应用程序上进行一些GUI测试. RDBMS是SQL Server2005.主机是Win Server 2003/IIS 6.0.

I'm currently doing some GUI testing on a ASP.net 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.

我注意到,当我重新启动IIS时,该应用程序运行良好,但是经过一些测试,在打开和关闭浏览器几个小时之后,该应用程序开始变得越来越慢.我想知道这种行为是否是由于程序员的错误关闭连接做法引起的:我怀疑这里的数据库存在打开的连接泄漏.

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.

我猜.Net垃圾收集器最终将关闭它们,但是...可能需要一段时间,不是吗?

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

我有SQL Server Management Studio,并且从活动监视器中确实注意到,数据库上有很多连接已打开.

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. 在SQL中有什么方法可以知道 Server 2005(如果存在连接) 开放,因为他们在等着 用于连接池或 它们是开放的,因为它们被 申请吗?

  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 application?

有人知道好事吗 我可以的在线/纸张资源 学习如何使用表现 柜台或其他工具 帮助追踪这类 问题?

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 issues?

如果性能计数器是最好的 解决方案,我有哪些变量 应该看吗?

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

推荐答案

您始终可以从web.config中检查连接字符串(主要是它们是否已激活连接池,是否已启用任何连接限制).

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

此外,如果您使用的是IIS 6,则可以将Web应用程序设置为使用单独的应用程序池,并设置其他选项来回收内存和进程.

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.

如果您有权访问sql server,则可以监视从应用程序建立的连接(为每个已安装的SQL Server实例定义了性能计数器).

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).

MSDN杂志中有一些文章.您也可以使用SOS调试库将其附加到应用程序的进程中,然后手动进行检查.

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.

并且,如果您没有源代码,请尝试使用 Reflector 获取应用程序的源代码(它们对于调试非常有用)

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)

@稍后您也可以在stackoverflow.com上查看此问题.

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

这篇关于如何检测ASP.net应用程序中的SqlServer连接泄漏?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆