Forum Moderators: phranque

Message Too Old, No Replies

VBScript runtime error

need help finding the bug

         

Raymond

7:21 am on Jan 12, 2005 (gmt 0)

10+ Year Member



I have received 2 reports of the following VBScript runtime error:

Microsoft VBScript runtime error '800a0007'
Out of memory

/inc/xyz.asp, line 9

That particular line of code executes the following line:

Redim Cart(8,total-1)

However, I cannot reproduce such error. Out of thousands of visitors per day, this only happens to a few of my visitors. I suspect there are actually more people who get this error, and only 2 reported it.

Anybody has any experience in this? Thank you in advance.

CaseyRyan

3:58 pm on Jan 12, 2005 (gmt 0)

10+ Year Member



Here's what the KB docs say about the max length of an array.
The length of every dimension of an array is limited to the maximum value of a Long data type, which is (2 ^ 64) - 1.

That's pretty big though (18446744073709551615).
Does Total-1 every get that large?

The only other possiblity is that you're literally running out of memory... could be what you are storing in the array is so large per item that you eventually get to big. Is there a way to optimize what you're doing/storing?

One thing you could do is try and trap the error when it happens and write out the array and any other pertinent information to a text file. This way when it happens you have a dump of what happened to try to debug it. You would also be able to fail gracefully and give the user a better error.

In order to do that, you'd do something like this:


On Error Resume Next
Err.Clear
Redim Cart(8,total-1)
If (Err.Number <> 0) Then
' Write Out Log Here
' Gracefully Exit
End If

-=casey=-

mattur

4:48 pm on Jan 12, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



It's possible to get this error msg when attempting to Redim an array using a negative number.

As casey suggested, stick some debugging code on your page, and check your code handles cases where total-1 is less than 0.

Raymond

6:51 pm on Jan 12, 2005 (gmt 0)

10+ Year Member



Problem is, I cannot reproduce the error. I just received 2 reports from my clients.

The largest value of the "total" variable is 100. The array only stores text that are shorter than 20 characters. It is hard to imagine how this array can consume 2G of memory.

CaseyRyan

7:03 pm on Jan 12, 2005 (gmt 0)

10+ Year Member



Trapping the error and logging the contents of the array will allow you to let the customer reproduce the error. You can watch the log files or wait for the report. Once you have the output you can see not only how often it is happening but also you will have all the values of the array, and other variables with which to debug.

Have you tried mattur's suggestion of checking to see if (Total-1 > 0)?

-=casey=-

Raymond

11:17 am on Jan 13, 2005 (gmt 0)

10+ Year Member



Thanks for the suggestions. I wrote a function to log what's going on when it processes that line. Now I will let it sit for a few days.

When I wrote this script, I also wrote an error detection module that traps errors. The module SHOULD reset all offending variables back to its default value when an error is detected. I just tested with a whole bunch of different values, and everything was caught by that module.