使用Server.CreateObject("ADODB.Connection")的经典ASP中的连接泄漏 [英] Connection leaks in Classic ASP using Server.CreateObject("ADODB.Connection")

查看:570
本文介绍了使用Server.CreateObject("ADODB.Connection")的经典ASP中的连接泄漏的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在查看一个现有的经典asp应用程序.设置如下:

I'm looking at an existing classic asp application. The setup is as follows:

  • db.asp:使用Server.CreateObject("ADODB.Connection")打开连接,然后调用conn.open
  • func.asp:具有帮助方法,可使用db.asp中的conn对象执行查询
  • index.asp:构建查询并调用func.asp中的方法

index.asp和func.asp都包含db.asp. index.asp包括func.asp否,conn.close的调用位置.

both index.asp and func.asp include db.asp. index.asp includes func.asp No where is conn.close called.

  1. 请求结束后,连接会自动关闭还是恢复?
  2. 当index.asp包含func.asp时,具有index.asp和func.asp包括db.asp的含义是什么?多个连接?
  3. 有没有计数器来检查建立的连接数?

我已经使用过sp_who2,但即使在不同的浏览器下运行,也只能看到1条记录.尝试使用集成安全性和连接字符串中的sql帐户进行此操作.

I've already used sp_who2 but only see 1 record for the application even when run under different browsers. tried this using both integrated security and a sql account in the connection string.

我查看了性能计数器,但数字从未改变.它们停留在5.MSSQL $ Instance:常规统计信息\逻辑连接和MSSQL $ Instance:常规统计信息\用户连接.

I looked in performance counters but the numbers never change. They stay at 5. MSSQL$Instance:General Statistics\Logical Connections and MSSQL$Instance:General Statistics\User connections.

我们正在生产中看到该应用程序的多达47个连接,但我无法在本地复制它.这些连接被列为睡眠状态,未执行.

We're seeing up to 47 connections from the app in production but I cannot reproduce it locally. The connections were listed as sleeping, not executing.

在IIS 7.5下运行经典asp

Running classic asp under IIS 7.5

推荐答案

  1. 否,连接保持打开状态,但是数据库驱动程序最终将终止它们.不过,这将需要几分钟,因此,如果访问者很多,则可以轻松达到数据库并发连接数的限制.
  2. 是的,如果您有多个包含要打开一个连接的代码,则最终会有多个连接.如果连接存储在同一个变量中,则对先前连接的引用将丢失,并且将保持打开状态以等待超时.
  3. 您可以在SQL Manager中查看数据库会话.但是,您将不容易看到返回到池的连接与等待超时的孤立连接之间的区别.

您应确保关闭和取消引用每个连接和每个记录集.示例:

You should make sure that every connection and every recordset are closed and dereferenced. Example:

rstData.Close
Set rstData = Nothing

conn.Close
Set conn = Nothing

这篇关于使用Server.CreateObject("ADODB.Connection")的经典ASP中的连接泄漏的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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