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 IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Application Popup

Status
Not open for further replies.

swade61970

Programmer
Apr 2, 2003
19
US
We have recently upgraded from Windows NT Server to Windows 2000 server and we now have some VB programs that are failing with the following popup error on the server:

Application popup: MemoryTest Part 2.exe - Application Error : The instruction at "0x77fcca14" referenced memory at "0xffffffff". The memory could not be "read".

The logic of the program is pretty straight forward. We connect to our AS/400 using an ADO connection, perform some SQL selects and then close the connection.

The program runs several hundred times a day. Every third day or so the program fails with the above message. We press OK and the other programs execute successfully.

We have recompiled the program. We have ran all of the critical Windows updates and have upgraded to MDAC 2.7 and it still breaks. I ran the program 200,000 times back to back on my Windows 2000 PC and it worked great.

Any suggestions.

 
A couple of suggestions:

* Can you write a debug report into the application that will add to a textfile, so you can find out which part of the application is causing the error on the server?
* Are all objects destroyed once they have been used? For example, if you create a recordset, and then run it again, and again, is the object destroyed at the end of each run, or merely recreated, as this will eat memory, and may explain why it runs fine, after the application is stopped, memory empties, and then is re-run.

Is this application running all the time, or is it only started when the queries are sent to the AS400?

BB
 
BB,

I have been able to reproduce bug on test 2000 server. I changed the program to do as little as possible to determine what is causing problem.

My first attempt was changing the VB pgm to only write to a log file. I ran that for 2 days straight without any errors.

My second attempt was changing the VB pgm to write to a log file as well as connect to AS400 and then close connection. That change causes the pgm to fail after about 45 minutes. Since I'm calling it over and over again, I can reproduce pretty easily.

As far as objects being destroyed, I only have one connection and I close it at the end of the program. I don't have anything in my code to kill anything.

Thanks for your assistance.
 
How are variable created within the application? Do you set your variables to nothing once you have finished using them? Are all of your variables declared within sub & functions or are they global variables?

BB
 
I learn by example, so please any input (pos or neg) is appreciated. Here is the code.

Option Explicit

Public is_Log As String
Public ib_LogFileAvailable As Boolean


Public Sub Main()

On Error Resume Next

Dim Input_file As String
Dim Output_file As String
Dim SearchChar As String
Dim J As Integer
Dim i As Integer
Dim Position As Long
Dim Input_line As String


'Define log file path and name
is_Log = "N:\StaffViewData\Logs\AgencyLetterValues.log"

OpenLogFile is_Log
PrintToLog "Test memory 2B"
CloseLogFile

SearchChar = """"

' Let's get our Staffview inputfile into our input_file variable here
J = InStr(2, Command$, SearchChar)
Input_file = Mid$(Command$, 2, J - 2)

' lets get our output abox file into the variable output_file
i = InStr(J, Command$, SearchChar)
Output_file = Mid$(Command$, J + 3, i - 4)


Dim cn As ADODB.Connection
Dim cm As New ADODB.Command
Dim szQry As String
Dim rcdAffected As Variant

'Establish a connection
Set cn = New ADODB.Connection
cn.CommandTimeout = 500
cn.ConnectionTimeout = 500
cn.ConnectionString = "Provider=IBMDA400;Data Source=SHEN02;User ID=SPYCONNECT;Password=xxxxxx;"
cn.Open


'Close the connection
cn.Close



End Sub


Sub OpenLogFile(as_Filename As String)
On Error GoTo OpenLogFile_Error
Open as_Filename For Append Shared As #3

ib_LogFileAvailable = True
Exit Sub

OpenLogFile_Error:
ib_LogFileAvailable = False
Exit Sub

End Sub


Sub PrintToLog(av_Info As Variant)
If ib_LogFileAvailable Then
Print #3, av_Info
End If
End Sub


Sub CloseLogFile()
On Error GoTo CloseLogFile_Error
Close #3

CloseLogFile_Error:
Exit Sub
End Sub

 
Where you have cn.close, place:

Rs.Close
Set Rs = Nothing
cn.Close
Set cn = Nothing

Where cn is your connection, and rs is your recordset. This will "empty" the memory each time you have finished using it.

BB
 
After you said something about clearing memory, I looked in a book and saw set cn = nothing. I tried it and it didn't resolve the issue. Thanks for the tip. I will use in the future.

I didn't answer your question earlier about whether or not the program runs continuously or on demand. Its called on demand over and over again.

Do you think it is something in my code or a system issue? The error pops up in the System Log of the Event viewer, not the application log.

 
What is the EventID and Source from your System Log.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top