Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

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

Posted on 2004-10-22
6
Medium Priority
?
1,319 Views
Last Modified: 2012-06-21
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?

Code:
Module1.bas
Global AddrContent(10) As String  'an array already filled with web addresses

Form1
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"
          DoEvents
          BlankpgString2 = Len(frmParser.txtSource.Text)
     Wend

    set objDocument = nothing
    set  objMSHTML = nothing
   'Even after setting the objects to nothing, it's still in memory
    GG3 = GG3 - 1
Loop
End Sub
0
Comment
Question by:blackbookcoder
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
6 Comments
 
LVL 32

Expert Comment

by:Erick37
ID: 12382462
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.
0
 

Author Comment

by:blackbookcoder
ID: 12392097
yes my mistake the set document  should be inside the loop.  Even setting them to nothing still makes a memory leak when changing urls
0
 
LVL 32

Expert Comment

by:Erick37
ID: 12393207
How are you determining that there is a memory leak?
0
 

Author Comment

by:blackbookcoder
ID: 12396573
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
0
 

Accepted Solution

by:
modulo earned 0 total points
ID: 12624134
PAQed with points refunded (500)

modulo
Community Support Moderator
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Suggested Courses

609 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question