Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


Re: IXMLDOMDocument.TransformNode 'leak' or somthing like it

From: rfaneuf@-------.---
To: NULL
Date: 12/2/2004 11:49:00 AM
Jonathan Chong wrote:
> Try to do this:
>
> BSTR transResult = pInpXML->transformNode(pXSL);
> ...
> ...
> ...
> if ( transResult )
>     ::SysFreeString(transResult);
>
> And free the transResult variable after using it.
>
>
> "Ross Faneuf" <rfaneuf@i...> wrote in message
> news:8fbf7730.0412011413.18911883@p......
> > We have a Windows service which imports data into various
databases.
> > It runs continuously, polling a directory for XML files to
transform
> > and import. The import code uses MSXML 4.0 in C++ through the smart
> > pointer interface to create two DOMDocument objects for each XML
file
> > and its transform. Boiled down, the code looks like this (extensive
> > error handling etc. removed):
> >
> > void CImportSvc::doXMLTransformAux(...)
> >    {
> >    MSXML2::IXMLDOMDocument2Ptr   pXSL = NULL;
> >    MSXML2::IXMLDOMDocument2Ptr   pInpXML = NULL;
> >    _bstr_t                       transArg;
> >    VARIANT_BOOL                  loadRes;
> >
> >    hr = pXSL.CreateInstance("Msxml2.DOMDocument.4.0");
> >    pXSL->setProperty("ServerHTTPRequest", true);
> >    pXSL->async = false;
> >
> >    try
> >       {
> >       loadRes = pXSL->load(<transform-file-name>);
> >       }
> >    catch( ... )
> >       {
> >       ...
> >       }
> >
> >    hr = pInpXML.CreateInstance("Msxml2.DOMDocument.4.0");
> >    pInpXML->setProperty("ServerHTTPRequest", true);
> >    pInpXML->async = false;
> >    try
> >       {
> >       loadRes = pInpXML->load(<xml-file-name>);
> >       }
> >    catch( ... )
> >       {
> >       ...
> >       }
> >
> >    try
> >       {
> >       transArg = pInpXML->transformNode(pXSL);
> >       }
> >    catch(_com_error &e)
> >       {
> >       CString        errDescription;
> >
> >       errDescription = (LPCTSTR) e.Description();
> >       // On failure, errDescription = "A dynamic link library (DLL)
> > initialization routine failed."
> >       }
> >
> >    // Free DOM objects
> >    pXSL = NULL;
> >    pInpXML = NULL;
> >    }
> >
> > This code works just fine approximately 600 times. Eventually,
> > pInpXML->transformNode fails and is caught with a _com_error, with
the
> > message shown above. Monitoring the process with Process Explorer
> > shows no obvious memory leak - private bytes does not increase
> > perceptibly.
> >
> > An outer routine surrounds this code fragment with
> > ::CoInitialize()/::CoUnitialize() each time this code fragment is
> > called. I have tried adding ::CoFreeAllLibraries() before
> > ::CoUnitialize(), and I have confirmed using Process Explorer that
> > msxml4.dll is unloaded; this has no effect. Presumably, MSXML
garbage
> > collection occurs when the library is unloaded.
> >
> > A symptom which appears in Process Explorer is handle consumption.
> > Each time pInpXML->transformNode(pXSL); is called (seen by stepping
in
> > debugger), a WmiGuid handle is consumed by the process; eventually
> > there are about 600, which are never freed. I don't know whether
this
> > handle is a symptom or cause of the problem, but it's the only
> > resource I've been able to find which is being consumed.
> >
> > This behavior is reproducible running on a single machine with
> > essentially no load on MSXML - this is not a busy Web Server
> > situation. I don't believe the issues addressed in MS articles
304227
> > or 297997 are relevant.
> >
> > Using MSXML 4.0 SP2.
> >
> > Anybody have a clue what's going on here?



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