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:
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.
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.