Altova Mailing List Archives>Archive Index >microsoft.public.xml Archive Home >Recent entries >Thread Prev - Re: IXMLDOMDocument.TransformNode 'leak' or somthing like it [Thread Next] Re: IXMLDOMDocument.TransformNode 'leak' or somthing like itTo: 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?
| ||||||
| Company | Legal | Press | Partners | Careers | Sitemap | Contact Us | Altova Blog | Mobile | Full Site | |||
|
