Creating MSXML2.DOMDocument60 and running out of memory

mchac

Well-known Member
Joined
Apr 15, 2013
Messages
531
I'm iteratively loading xml documents into a the object oInstance, searching for data in the docs then repeating.

The code that loads the documents is:
Code:
Private Sub LoadInstanceDocIntoMemory(COUNTER As Long)


    If ActiveCell.Offset(COUNTER, 0) <> "" Then
    
        Set oInstance = Nothing
        Set oInstance = New MSXML2.DOMDocument60
        oInstance.async = False
        oInstance.validateOnParse = False
        oInstance.Load "http://" & ActiveCell.Offset(COUNTER, 0)
    
        If oInstance.parseError.ErrorCode <> 0 Then
            MsgBox "Error loading file: " & vbCrLf & vbCrLf & _
                "File URL: " & oInstance.parseError.URL & vbCrLf & _
                "Error Code: " & oInstance.parseError.ErrorCode & vbCrLf & _
                "Error Description: " & oInstance.parseError.reason & vbCrLf _
                , vbCritical
        End If
    
    Else
        Set oInstance = Nothing
    
    End If


End Sub

After about a while I get an out of memory error and I can see that the memory allocated to Excel is large at about 300k. I hit Debug, then Run and got the same error after about the same number of iterations when the Excel memory was at about 500k.

I'm wondering what I'm not doing to clear memory that I should.

I set oInstance to Nothing at each iteration but I'm also creating a New MSXML2.DOMDocument60 at each iteration. Is this the correct methodology or should I 'clear' and 'reuse' an existing MSXML2.DOMDocument60.

Let me know if I'm not being clear enough, I'm new to doing things with XML so I don't know what's needed to help trouble shoot.

Any help or references is appreciated.
 

Excel Facts

Can Excel fill bagel flavors?
You can teach Excel a new custom list. Type the list in cells, File, Options, Advanced, Edit Custom Lists, Import, OK

Forum statistics

Threads
1,215,133
Messages
6,123,235
Members
449,092
Latest member
SCleaveland

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top