Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Out of Memory Error 1

Status
Not open for further replies.

k8277

Programmer
Jan 10, 2003
104
0
0
US
I have a line of code that is randomly giving users a problem:

Redim yArray(3,Ubound(xArray,2)-1)

In the IIS log file it gives me a 500 Out of Memory. The server has 2GB and pretty much runs with 1.3GB free. Other posts on the net have said this could be caused by two things in the second dimension of yArray: 1. A negative value or 2. a really large value.
I have tested both cases and they do not give me the Out of Memory error, instead I get subscript out of range or overflow.

Does anybody know what else might cause this?
 
Perhaps debug by calculating the second dimension into a variable, adding an error trap, and then writing to a log when it happens.


Something like this:
[tt]
Dim MyVal
MyVal = Ubound(xArray,2) - 1
on error resume next
Redim yArray(3,MyVal)
if err.Number <> 0 then
Dim oFSO, oTXT
set oFSO = Server.CreateObject("Scripting.FileSystemObject")
set oTXT = oFSO.CreateTextFile("log.txt", true)
oTXT.WriteLine "MyVal = " & MyVal
oTXT.WriteLine "Error Description: " & Err.Description
oTXT.Close
set oTXT = Nothing
Set oFSO = Nothing
Response.Write "Sorry, Bad error. Call Steve."
Response.End
end if
on error goto 0
[/tt]

I didnt test this... just typed it.. so probably has some syntax or other errors... its just to give you an idea.


oh, and also i suppose the error might also be caused by the sub expression: Ubound(xArray,2)
 
The problem is most probably:
[tt] Ubound(xArray,2) = -1[/tt]
already. Redim to dimension < -1 is out-of-memory. It can roughly apprehended as dimension FFF...E (a big dimension).

As the op has tried to reproduce problem, here is a demo.

[tt]dim a()
redim a(-1) 'no problem, roughly same as making it uninitiated
on error resume next
redim a(ubound(a)-1)
if err.number <>0 then
response.write hex(err.number) & "<br />" & err.description
err.clear
end if
on error goto 0
[/tt]
 
tsuji -

I tried your demo code and yes it does produce the out of memory error. I guess I need to determine how the condition ** Ubound(xArray,2) = -1 ** comes about.

Thanks for the help.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top