Internet Explorer and Memory

From: Richard Bell (rbell01824_at_earthlink.net)
Date: 08/04/04


Date: Wed, 04 Aug 2004 23:29:09 GMT


I'm using VBSCRIPT to automate Internet Explorer and repeatedly
navibate to a set of several hundred web pages. Over time the system
is running slower and slower. Investigation shows that memory is
gradually decreasing per perfmon memory KB available. Examination
with windows task manager shows several copies of iexplorer (one for
each pass). It appears that I'm not properly closing and releasing
iexplorer and that it remains in the task list, draining memory and
slowing the system down.

I start and stop IE with the following code in a vbs that is executed
by a shell.run command.

Several questions:

Do I need to do something besides g_oIE.Quit to actually terminate IE
and get it removed from the process list?

Since the g_oIE.Quit is in its own vbs, shouldn't its termination
release all of its resources? If not, what do I need to do to force
the resources to release?

Thanks for any clues.

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

' code to start/stop IE

Sub IEStart()
        On Error Resume Next
        Set g_oIE =
WScript.CreateObject("InternetExplorer.Application", "g_oIE_")
        g_oIE.Visible = True ' make
visible on the screen
        if err.number <> 0 then
                Out( "InternalErrorIEStart1," & Err.number & "," &
Err.Description & "," & Err.Source )
                err.Clear
        end if
        WScript.Sleep 2000 ' give
IE a chance to start
        'Do While (g_oIE.Busy):Loop ' Important:
wait till MSIE is ready
        g_boIE = true ' ie
is up and ready
        if err.number <> 0 then
                Out( "InternalErrorIEStart2," & Err.number & "," &
Err.Description & "," & Err.Source )
                err.Clear
        end if
        On Error Goto 0
End Sub

Sub IEStop()
        if g_oIE.Busy then ' stop IE
                g_oIE.Stop
        end if
        if err.number <> 0 then
                Out( "InternalErrorIEStop1," & Err.number & "," &
Err.Description & "," & Err.Source )
                err.Clear
        end if
        ' Do While (g_oIE.busy):Loop
        WScript.Sleep 2000 ' give IE a chance to start
        g_oIE.Quit
        Set g_oIE = Nothing
        Out( "IEQuit" )
        if err.number <> 0 then
                Out( "InternalErrorIEStop2," & Err.number & "," &
Err.Description & "," & Err.Source )
                err.Clear
        end if
        On Error Goto 0
End Sub



Relevant Pages

  • Internet Explorer and Memory
    ... is running slower and slower. ... gradually decreasing per perfmon memory KB available. ... release all of its resources? ... Sub IEStart() ...
    (microsoft.public.scripting.vbscript)
  • How GC Works
    ... one contains the memory part and other manages the ... unmanaged resources and implement finalize in the second class so that ... allocates large memory as classes implementing finalize method requires ... Sub New ...
    (microsoft.public.dotnet.framework.clr)
  • Garbage Collection
    ... one contains the memory part and other manages the ... unmanaged resources and implement finalize in the second class so that ... allocates large memory as classes implementing finalize method requires ... Sub New ...
    (microsoft.public.dotnet.framework.clr)
  • Re: memory leak using system.windows.forms.timer
    ... > subroutine, memory leaks. ... > Private Sub CheckComputers() ... > Dim intCount As Integer ... > Dim mySearcher As New ...
    (microsoft.public.dotnet.languages.vb)
  • Re: memory leak using system.windows.forms.timer
    ... subroutine, memory leaks. ...     Private Sub CheckComputers() ... subroutine with a static number I still leak memory. ...
    (microsoft.public.dotnet.languages.vb)