VBScript中内存不足的错误 [英] VBScript Out Of Memory Error

查看:218
本文介绍了VBScript中内存不足的错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个由第三方公司建立了一个传统的ASP CRM。目前,我有机会获得源$ C ​​$ c和我能做出所需的任何更改。

随机全天,一般经过用户的一些使用较长一段时间,我的大部分页面开始得到一个内存不足的错误。

应用程序的构建方式,是所有页面和脚本拉动核心功能从Global.asp文件。在该文件中嵌入影片是全球其他文件为好,但错误presented显示


  

内存不足


  
  

WhateverScriptYouTriedToRun.asp线0


0线是包括对global.asp文件。一旦错误发生时,错误occurence平息了一段时间,但随后未指定的时间量后开始再次重演。随着应用程序是怎么写的,它使用的功能,和诊断我已经做了 - 它似乎是被隐瞒,如记录或类似这种事情的数据,然后无法正常释放它一个常用功能。其他用户然后尝试使用相同的功能,最终它只是填补了导致错误。对我来说,只有这样,才能有效地清除错误是实际重新启动IIS,回收应用程序池,并重新启动SQL Server服务。

不用说,我和我的用户惹恼....

我不能查明错误,由于实际的错误信息presented为0线 - 但是从那里我不知道在哪里的20K线$ C $的c那么它可以挂起来。如何隔离或至少点我在正确的方向,开始清理这件事的任何想法或意见?是否有我的方式来增加对VBScript的记忆的大小?我知道有一个限制,但它是设定在说... 512K可以将它提高到1GB?

下面有东西我曾尝试:


  1. 删除SQL语句内嵌到浏览

  2. 通过几百个脚本去,确保每一个OpenConnection的&安培; OpenRecordSet其次是适当关闭。

  3. 通过全球文件去和注释掉任何大的SQL语句,如ApplicationLog(即写入执行的查询到表中的功能)。

  4. 一些规模较小的脚本编辑。


解决方案

通用内存泄漏

你说你是关闭所有的记录和连接这是很好的。

但是你删除的对象?

例如:

 设置adoCon =新
设置rsCommon =新做查询的东西'你做这个:
rsCommon.close
adocon.close但是,你这样做吗?
设置adoCon =什么
设置rsCommon =什么

没有垃圾收集在传统的ASP,所以不被破坏将保留在内存中。任何物体

此外,确保您的关闭/空话在每一个分支运行。例如:

  adocon.open
rscommon.open等SQL查询
MYDATA的= rscommon(条件)如果(MYDATA的),然后
  回复于(OK)
其他
  的Response.Redirect(error.asp)
万一'关
rsCommon.close
adocon.close
设置adoCon =什么
设置rsCommon =什么

没有关闭/重定向之前被销毁,因此只会空内存在某些时候不逻辑牵头各分公司,以合适的存储间隙。

更好的设计

也不幸这听起来像该网站并没有设计好。我总是我的结构传统的ASP为:

 <%
    显式的选项    申报所有瓦尔
    这暗淡
    那暗淡    打开连接
    设置adoCon ...
    adocon.open()    获取所需的数据
    rscommon.open STRSQL,adoCon
        此= rsCommon.getRows()
    rsCommon.close    取别的东西
    rscommon.open STRSQL,adoCon
        该= rsCommon.getRows()
    rsCommon.close    关闭连接和删除对象
    adoCon.close
    设置adoCon =什么
    设置rscommon =什么    处理重定向
    如果(条件),然后
        的Response.Redirect(URL)
    万一
%GT;
< HTML和GT;
<身体GT;<%
    使用数据
    对于(i = 0到UBOUND(此,2)
        回复于(这(0,I)及与&​​amp;该​​(1,I)及&所述峰; br />中)
    下一个
%GT;< /身体GT;< / HTML>

希望一些这帮助。

I have a classic ASP CRM that was built by a third party company. Currently, I have access to the source code and am able to make any changes required.

Randomly throughout the day, usually after some prolonged usage by users, most of my pages start getting an Out of Memory error.

The way that the application is built, is all the pages and scripts pull core functions from a Global.asp file. In that file are embeds to other global files as well, but the error presented shows

Out Of Memory

WhateverScriptYouTriedToRun.asp Line 0

Line 0 is the include for the global.asp file. Once the error occurs, after an unspecified amount of time the error occurence subsides for some time but then begins to reoccur again. With how the application is written, and the functions it uses, and the "diagnostics" I've already done - it seems to be a common used function that is withholding data such as recordset or something of that nature and then not releasing it properly. Other users then try to use the same function and eventually it just fills up causing the error. The only way for me to effectively clear the error is to actually restart IIS, Recycle the App Pool, and Restart the SQL Server Services.

Needless to say, myself and my users are getting annoyed....

I can't pinpoint the error due to the actual error message presented being Line 0 - but from there I have no idea where in the 20K lines of code it could be hanging up. Any thoughts or ideas on how to isolate or at least point me in the right direction to begin clearing this up? Is there a way for me to increase "memory" size for VBScript? I know there is a limitation but is it set at say...512K and you can increase it to 1GB?

Here are things I have tried:

  1. Removing SQL Inline statements into Views
  2. Going through several hundred scripts and ensuring that every OpenConnection & OpenRecordSet is followed by an appropriate Close.
  3. Going through the Global File and commenting out any large SQL statements such as ApplicationLog (A function that writes the executed query into a table).
  4. Some smaller script edits.

解决方案

Common Memory Leak

You say you are closing all recordsets and connections which is good.

But are you deleting objects?

For example:

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

No garbage collection in classic ASP, so any objects not destroyed will remain in memory.

Also, ensure your closes/nothings are run in every branch. For example:

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

Nothing is closed/destroyed before the redirect so it will only empty memory some of the time as not all branches of logic lead to the proper memory clearance.

Better Design

Also unfortunately it sounds like the website wasn't designed well. I always structure my classic ASP as:

<%
    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>

Hope some of this helped.

这篇关于VBScript中内存不足的错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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