Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


RE: Optimizing code for load in MSXML 4.0

From: malhenry@-----------.---------.---
To: 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!!


transparent
Print
Mail
Like It
Disclaimer
.

These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.

.
.

transparent

transparent