Rog*_*r00 4 vbscript out-of-memory asp-classic
我有一个由第三方公司建立的经典ASP CRM.目前,我可以访问源代码,并且可以进行任何更改.
随机地全天,通常在用户长时间使用之后,我的大多数页面都开始出现Out of Memory错误.
构建应用程序的方式是,所有页面和脚本都从Global.asp文件中提取核心功能.在该文件中也嵌入了其他全局文件,但显示的错误显示
内存不足
WhateverScriptYouTriedToRun.asp第0行
第0行是global.asp文件的include.一旦发生错误,在一段未指定的时间之后,错误发生在一段时间内消退,但随后又开始再次发生.关于应用程序的编写方式,它使用的功能,以及我已经完成的"诊断" - 它似乎是一个常见的使用函数,它隐藏了记录集之类的数据或者那种性质的东西,然后没有正确地释放它.然后其他用户尝试使用相同的功能,最终它只是填满导致错误.我有效清除错误的唯一方法是实际重启IIS,回收应用程序池,然后重新启动SQL Server服务.
不用说,我和我的用户都很生气....
由于实际的错误消息显示为第0行,我无法查明错误 - 但是从那里我不知道在20K行代码中它可能会挂起.关于如何隔离或至少指出我正确的方向以开始清理它的任何想法或想法?有没有办法让我增加VBScript的"内存"大小?我知道有一个限制但它设置为... 512K你可以增加到1GB?
以下是我尝试过的事情:
常见的内存泄漏
你说你正在关闭所有好的记录集和连接.
但是你要删除对象吗?
例如:
Set adoCon = new
Set rsCommon = new
'Do query stuff
'You do this:
rsCommon.close
adocon.close
'But do you do this?
Set adoCon = nothing
Set rsCommon = nothing
Run Code Online (Sandbox Code Playgroud)
经典ASP中没有垃圾收集,因此任何未销毁的对象都将保留在内存中.
此外,确保在每个分支中运行关闭/未关闭.例如:
adocon.open
rscommon.open etc
'Sql query
myData = rscommon("condition")
if(myData) then
response.write("ok")
else
response.redirect("error.asp")
end if
'close
rsCommon.close
adocon.close
Set adoCon = nothing
Set rsCommon = nothing
Run Code Online (Sandbox Code Playgroud)
在重定向之前没有任何东西被关闭/销毁,因此它只会在某些时候清空内存,因为并非所有逻辑分支都会导致正确的内存清除.
更好的设计
还不幸的是,这听起来像网站设计不好.我总是将我的经典ASP构建为:
<%
Option Explicit
'Declare all vars
Dim this
Dim that
'Open connections
Set adoCon...
adocon.open()
'Fetch required data
rscommon.open strSQL, adoCon
this = rsCommon.getRows()
rsCommon.close
'Fetch something else
rscommon.open strSQL, adoCon
that = rsCommon.getRows()
rsCommon.close
'Close connections and drop objects
adoCon.close
set adoCon = nothing
set rscommon = nothing
'Process redirects
if(condition) then
response.redirect(url)
end if
%>
<html>
<body>
<%
'Use data
for(i = 0 to ubound(this,2)
response.write(this(0, i) & " " & this(1, i) & "<br />")
next
%>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)
希望其中一些有所帮助.
| 归档时间: |
|
| 查看次数: |
9554 次 |
| 最近记录: |