Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8196161
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T05:23:26+00:00 2026-06-07T05:23:26+00:00

I have a VBA Macro script that scrapes some data. It’s scrapes it using

  • 0

I have a VBA Macro script that scrapes some data.
It’s scrapes it using MSIE.. I believe the MSIE is the core problem to the memory leakage.

I’m initializing the variable like

Set IE = CreateObject("InternetExplorer.Application")

I made a little test to see how the memory is being used.

I made a loop which makes only 1 instance of IE and pings the same website.
Memory doesn’t seem to leek.

Then I made a loop which always ping a different site and memory usage started increasing with each request.

I also made a test (I’m posting below) that creates NEW object in every iteration and deletes it on the end. The deleting part doesn’t seem to work.

It seems like the instance of IE is caching the requests so the object is getting bigger.
This is just an assumption.

Here’s the sample code I used to test the leakage.

Do While True
    Dim IE As Object
    Set IE = CreateObject("InternetExplorer.Application")

    IE.Navigate "https://www.google.hr/#hl=hr&gs_nf=1&cp=3&gs_id=8&xhr=t&q=" & Counter
    IE.Visible = True

    Do While IE.readyState <> 4 Or IE.Busy = True
        Application.Wait Now() + TimeValue("00:00:01")
        DoEvents
    Loop

    Application.Wait Now() + TimeValue("00:00:01")
    Counter = Counter + 1
    Range("A" & Counter).Value = "https://www.google.hr/#hl=hr&gs_nf=1&cp=3&gs_id=8&xhr=t&q=" & Counter

    IE.Quit
    Set IE = Nothing
Loop

Any input would be great!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T05:23:27+00:00Added an answer on June 7, 2026 at 5:23 am

    I tested the above code and it was destroying the IE Object correctly. Also in regards to this

    It seems like the instance of IE is caching the requests so the object is getting bigger. This is just an assumption.

    Yes it sometimes increases it but not always. See screenshot.

    enter image description here

    This is a screenshot of task manager for IE for 8 loops. It shows an increase but if you see it also brings it down. So I believe what you are seeing is not a memory leak.

    EDIT

    Here is some code that I had in my databank (I didn’t write it) but you can run it to check the memory usage.

    Sub Sample()
        Do While True
            Dim IE As Object
            Set IE = CreateObject("InternetExplorer.Application")
    
            IE.Navigate "https://www.google.hr/#hl=hr&gs_nf=1&cp=3&gs_id=8&xhr=t&q=" & Counter
            IE.Visible = False
    
            Debug.Print GetProcessMemory("iexplore.exe")
    
            Do While IE.readyState <> 4 Or IE.Busy = True
                Application.Wait Now() + TimeValue("00:00:01")
                DoEvents
            Loop
    
            Application.Wait Now() + TimeValue("00:00:01")
            Counter = Counter + 1
            Range("A" & Counter).value = "https://www.google.hr/#hl=hr&gs_nf=1&cp=3&gs_id=8&xhr=t&q=" & Counter
    
            IE.Quit
            Set IE = Nothing
        Loop
    End Sub
    
    Private Function GetProcessMemory(ByVal app_name As String) As String
        Dim Process As Object, dMemory As Double
    
        For Each Process In GetObject("winmgmts:"). _
        ExecQuery("Select WorkingSetSize from Win32_Process Where Name = '" & app_name & "'")
            dMemory = Process.WorkingSetSize
        Next
        If dMemory > 0 Then
            GetProcessMemory = ResizeKb(dMemory)
        Else
            GetProcessMemory = "0 Bytes"
        End If
    End Function
    
    Private Function ResizeKb(ByVal b As Double) As String
        Dim bSize(8) As String, i As Integer
        bSize(0) = "Bytes"
        bSize(1) = "KB" 'Kilobytes
        bSize(2) = "MB" 'Megabytes
        bSize(3) = "GB" 'Gigabytes
        bSize(4) = "TB" 'Terabytes
        bSize(5) = "PB" 'Petabytes
        bSize(6) = "EB" 'Exabytes
        bSize(7) = "ZB" 'Zettabytes
        bSize(8) = "YB" 'Yottabytes
        For i = UBound(bSize) To 0 Step -1
            If b >= (1024 ^ i) Then
                ResizeKb = ThreeNonZeroDigits(b / (1024 ^ _
                    i)) & " " & bSize(i)
                Exit For
            End If
        Next
    End Function
    
    Private Function ThreeNonZeroDigits(ByVal value As Double) As Double
        If value >= 100 Then
            ThreeNonZeroDigits = FormatNumber(value)
        ElseIf value >= 10 Then
            ThreeNonZeroDigits = FormatNumber(value, 1)
        Else
            ThreeNonZeroDigits = FormatNumber(value, 2)
        End If
    End Function
    

    SNAPSHOT

    enter image description here

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a VBA script that inserts long strings into Excel cells. In some
Excel 2002 VBA. I have a macro that launches an external script whenever a
I have a VBA macro that validates user entered data (I didn't use data
I have a problem in a VBScript that I am using with a VBA/Excel
I have a VBA Word Macro that gets words from .txt list and color
I have written a VBA macro in an excel spreadsheet that opens all workbooks
I have some VBA code that needs to talk to a running c# application.
I have a VBA script that imports a layout into an exsting drawing, its
I have a VBA macro for Microsoft Word that I am trying to improve.
I have an Excel VBA macro that creates a folder tree based on an

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.