Note that there are some explanatory texts on larger screens.

plurals
  1. POUsing Excel 2010 VBA loop to load xml file, extract info, repeat: results in excel out of memory error
    primarykey
    data
    text
    <p>I'm working in Excel 2010, Win 7 32bit, 4gb ram.</p> <p>I need to extract info from SEC filings (10-A and 10-K) using XBRL (which is basically an accounting tagging convention embedded in XML). Most public companies file reports in this format and there is a unique URL for each filing.</p> <p>Here are some examples:</p> <p>1 800 FLOWERS: <a href="http://www.sec.gov/Archives/edgar/data/1084869/000110465913082760/flws-20130929.xml" rel="nofollow">http://www.sec.gov/Archives/edgar/data/1084869/000110465913082760/flws-20130929.xml</a></p> <p>HERSHEY: <a href="http://www.sec.gov/Archives/edgar/data/47111/000004711113000036/hsy-20130929.xml" rel="nofollow">http://www.sec.gov/Archives/edgar/data/47111/000004711113000036/hsy-20130929.xml</a></p> <p>I have 43k of these URLs in a column in a sheet and I'm able to extract the info I need.</p> <p>However, as my Sub iterates down that list the memory used by Excel continues to increase until I get an out of memory error. Looking at Task Manager the 'Working Set (Memory)' starts at about 100k, 'Memory (Private Working Set)' starts at about 52k and 'Commit Size' starts at about 62k. </p> <p>As you can see in the code below I set the object that the XML is loaded into to Nothing but there doesn't seem to be any impact if I comment it out.</p> <p>If I close the excel sheet only about half of the allocated memory increase is released. I need to exit excel and reopen it to release/reset the memory allocated.</p> <p>Here's the code I use to load the XML doc. The Sub that calls this sub sets oInstance = Nothing at the end of the current iteration. Happy to provide that code.</p> <p>Sorry for the way this is appearing. I'm spacing 8 then copy paste from VBA but obviously doing something wrong.</p> <pre><code> Private oInstance As MSXML2.DOMDocument60 Private oNodelist As MSXML2.IXMLDOMNodeList Private COUNTER As Long Private Sub LoadInstanceDocIntoMemory() If ActiveCell.Offset(COUNTER, 0) &lt;&gt; "" Then Set oInstance = New MSXML2.DOMDocument60 oInstance.async = False oInstance.validateOnParse = False oInstance.Load "http://" &amp; ActiveCell.Offset(COUNTER, 0) If oInstance.parseError.ErrorCode &lt;&gt; 0 Then MsgBox "Error loading file: " &amp; vbCrLf &amp; vbCrLf &amp; _ "File URL: " &amp; oInstance.parseError.URL &amp; vbCrLf &amp; _ "Error Code: " &amp; oInstance.parseError.ErrorCode &amp; vbCrLf &amp; _ "Error Description: " &amp; oInstance.parseError.reason &amp; vbCrLf _ , vbCritical End If End If End Sub </code></pre> <p>I would appreciate it if anyone has a suggestion of how I can avoid this memory creep.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload