possible memory leak VB.Net app automating IE6 under XP Pro ... looking for clues

  • Thread starter Thread starter Richard Bell
  • Start date Start date
R

Richard Bell

I'm having difficulty with memory loss on an application that
automates IE6 under XP (pro, fully up to date) using VB.Net. Every 30
minutes (triggered by the XP scheduler) the application visits a
number (100s) of web sites. I noted that the system began running
slower and slower over time and was trying to understand what was
going on. I'm using performance monitor to track available memory,
send/recv bytes per second, etc. In looking at the perf mon results,
memory decreases during each run and is partially restored when the
run completes. Over time (days) memory degrades and the system
continues to run progressively slower.

Has anyone had similar experiences with long term heavy use of IE6
under XP? Does anyone have an idea of what might be causing the loss?
Does anyone have any idea of how to determine what component (VB,
..NET, IE6, ??) might be leaking memory?

Thanks for any clues.

Richard
 
How do you automate it (using the webbrowser?)

The automation is via the SHDocVw.InternetExplorer object. Automation
generally appears to be sound, at least insofar as it is functional,
with few hangs ( on the order of .5 per day). Unfortunately the hangs
are so infrequent that I've not been able to gain much insight into
the hang issue. In the end, it turns out that the hangs are more of a
nuisance than a problem as the system scheduler will delete the hung
run (leaving the IE object still alive) and re-run the application at
the next 30 minute interval. Additionally, memory degradation occurs
absent the hangs. All that said, I'm somewhat suspicious that IE
leaks memory but since both IE and the application terminate and
memory still leaks, I'm not really sure.

R
 
Hi Richard,

Have you build it in a component so that I disposable is implemented?

Cor
 
Cor,

I've been out of town for a few days.
Have you build it in a component so that I disposable is implemented?

Here is what I think is the relevant code (BTW, while I'm a very
experienced programmer, I'm still fairly new to VB):

==========================================

Class TestData
...
Public WithEvents oIE As SHDocVw.InternetExplorer ' the copy
of IE we automate
...
Sub RunTest()
...
If Not SetupIE() Then Return ' start IE or quit
For Each urle In Me.alURLEntries ' loop through list of
URLs
DoThisURL(urle) ' actually process this URL
Next

Me.oIE.Quit() ' close my IE
OutLogNL("EndTest")
End Sub

Function SetupIE() As Boolean ' create an IE to automate
Try
Me.oIE = New SHDocVw.InternetExplorer ' create teh
IE object
Catch ex As Exception ' die on failure
OutLogNL("Tester: Unable to setup IE " & ex.ToString)
Return False
End Try
Me.oIE.Visible = True ' make IE visible
Return True
End Function
....
End Class

....
Public oTestData As TestData ' the test data
....

Sub Main()
oTestData = New TestData ' create our test data object
GetArguments() ' get all our arguments, into
oTestData
'oTestData.DumpURLs()
OutLogSetup() ' setup our output files
oTestData.RunTest() ' actuall run the test
Cleanup() ' do any cleanup
End Sub

==========================================

While I'm new to VB, my understanding is that this will insure that
all storage will be unallocated when the application terminates so
that I need not explicitly deallocate either oTestData or the
contained objects. Is this correct?

Your question caused me to wonder if I might have memory leaking from
some other source. I explicitly create via New a number of
System.Threading.AutoResetEvent and ArrayList ( and its content). As
above, my understanding is that these need not be explicitly released
when the application terminates.

Finally I create some file I/O handles

Public fsFileLog As StreamWriter ' the log file
Public fsFileOut As StreamWriter ' the output file

but go to some care to insure that they are closed before the program
terminates.

Does any of this appear to be doubtful?

Thanks,
Richard
 
Hi Richard,

I think that the problem is that you are using a unmanaged resource without
that Idisposable is implemented.

To use that you can create your class in a component and place the
constructions in the right places (just look how it is done in a form).

(Just add a component item to your IDE and than some copying and pasting, it
is not as difficult as you first think when you read what is written below).

http://msdn.microsoft.com/library/d...rfSystemComponentModelComponentClassTopic.asp

I gues (however I am not sure) that you get than a better result.

Cor
 
Cor,

Thanks, I'll look into that some more, but at first glance IComponent
seems to be part of forms oriented applications and this is a command
line app.

R
 
Back
Top