objMSHTML As New MSHTML.HTMLDocument and leaking memory. How to terminate the object and stop the leaking memory?

Please look at this comment and then look at my code below
comment:   http://www.codeguru.com/vb/vb_internet/html/comments.php/c4815/?thread=54278
dispose of it in Form_Terminate?  How do I do that?

Global AddrContent(10) As String  'an array already filled with web addresses

Option Explicit

Dim objMSHTML As New MSHTML.HTMLDocument
Dim objDocument As MSHTML.HTMLDocument
Dim BlankpgString2 As Long

Public Sub GetWebpage()
Set objDocument = objMSHTML.createDocumentFromUrl(AddrContent(GG3), vbNullString)

Do Until GG3 = 0

     While objDocument.readyState <> "complete"
          lblStatus.Caption = "Waiting for the document to load"
          BlankpgString2 = Len(frmParser.txtSource.Text)

    set objDocument = nothing
    set  objMSHTML = nothing
   'Even after setting the objects to nothing, it's still in memory
    GG3 = GG3 - 1
End Sub
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Shouldn't the line:

Set objDocument = objMSHTML.createDocumentFromUrl(AddrContent(GG3), vbNullString)

be INSIDE the Do Until GG3 = 0 Loop?

Do Until GG3 = 0
    Set objDocument = objMSHTML.createDocumentFromUrl(AddrContent(GG3), vbNullString)
    While objDocument.readyState <> "complete"

As it is now, you set the MSHTML docs to nothing and keep looping.  On the second pass, since you have not SET objDocument you should get an error.

Setting them to Nothing as you have is sufficient and there should be no memory leak.
blackbookcoderAuthor Commented:
yes my mistake the set document  should be inside the loop.  Even setting them to nothing still makes a memory leak when changing urls
How are you determining that there is a memory leak?
blackbookcoderAuthor Commented:
Erick37, I'm using AQtime version 4.20 found at:  http://www.automatedqa.com/downloads/
I can see three threads which are not being released.  You can also read about tracking down memory leaks with other tools like poolmon.exe as described in this article:  http://www.winnetmag.com/Articles/Index.cfm?ArticleID=4754
PAQed with points refunded (500)

Community Support Moderator

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic Classic

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.