Altova Mailing List Archives>Archive Index >microsoft.public.xml Archive Home >Recent entries >Thread Prev - Optimizing code for load in MSXML 4.0 [Thread Next] RE: Optimizing code for load in MSXML 4.0To: NULL Date: 12/6/2005 12:18:00 PM I ran both of the algorithms for 20 minutes in perfmon and found the new
algorithm appeared to be much better in limiting handle counts (varying
between 181-188) than the old algorithm (varying between 162-308).
However, the new algorithm had a higher byte count then the old algorithm.
Would there be a reason for this other than the memory used by the load
method call is NOT getting released? Any comments on my algorithms above are
welcomed.
Thanks.
"malhenry" wrote:
> I am using MSXML 4.0 with VC++ 6.0 and am trying to optimize my code which
> processes xml files. My real question is does the load method below free the
> memory used by the prior xml doc that was loaded?
>
> My original pseudo code was:
>
> Loop
> //start constructor
> ::CoInitialize(NULL);
> hr = ::CoCreateInstance(...);
> //end constructor
> // process the xml
> ...
> CHECKHR(pDoc->put_async(VARIANT_FALSE));
> CHECKHR(pDoc->put_validateOnParse(VARIANT_FALSE));
>
> // Load xml document from the given URL or file path
>
> VariantInit(&vURL);
> vURL.vt = VT_BSTR;
> V_BSTR(&vURL) = pBURL;
> CHECKHR(pDoc->load(vURL, &vb));//****KEY call
>
> CHECKHR(CheckLoad(pDoc));
>
> CleanUp:
> SAFERELEASE(pXMLError);
> ...
> //start destructor
> if (m_pDoc)
> {
> unsigned long ul;
> ul = (m_pDoc)->Release();
> m_pDoc = NULL;
> }
> // free the string allocated by StringToBSTR that contains xml filename
> if (m_pBURL != NULL)
> ::SysFreeString(m_pBURL);
> ::CoUninitialize(); //returns a void
> //end destructor
>
> //ENDLOOP
>
> What I did to try to improve the code above was to move the constructor and
> destructor OUT of the loop so that they should only get called once. I added
> to the bottom of the loop a if (m_pBURL != NULL)
> ::SysFreeString(m_pBURL); so that the memory associated with the xml
> filename would be freed.
>
> I thought the load call would free the memory used by the prior xml doc
> processed. However, I am seeing a HIGHER usage of memory outstanding with
> the second version of my code using a memory analysis tool.
>
> Am I mistaken that load will also free memory? Should I go back to the
> original version of my code which seems inefficient to initialize and
> de-initialize com for every xml file I must process? Any advice?
>
> Thanks!!
| ||||||
| Company | Legal | Press | Partners | Careers | Sitemap | Contact Us | Altova Blog | Mobile | Full Site | |||
|
