Anurag,
you are importing a DOM tree into an existing DOMDocument (returned by the external getDocument() function call); we don't know what you are doing with this DOMDocument object, but if you don't release it, that's where the memory leak is.

Alberto

Anurag Jain wrote:
This implementation (code below )  leaks memory on solaris (when we call it 
serveral times) with xerces 2.7 and also xerces 2.8  , does anyone see a 
problem with it ...
 if we remove the DOMDocument importNode function call it stops leaking ..We 
are especialy interested in fixing this with xerces 2.7


Also NOTE : we do release the importing document at the end but that does not free up the memory either. All help is appreciated .

 Thanks
 -Anurag
>
>    string xml = <some large xml>;// around 200 KB
>     DOMNode* returnNode = NULL;
>     DOMNode* newNode = NULL;
>     XMLCh id[7];
>     try{
>         string idString="xmlDoc";
> > XMLString::transcode((const char*)idString.c_str(),id,6);
>         MemBufInputSource* mbis = new (XMLPlatformUtils::fgMemoryManager) 
MemBufInputSource  ( (const XMLByte*)xml.c_str(),
>                                 (unsigned int)xml.length(),
>                                 id,
>                                 false,XMLPlatformUtils::fgMemoryManager );
>         mbis->setCopyBufToStream(false);
>         //xercesc::XercesDOMParser * parser= new xercesc::XercesDOMParser;
>         XercesDOMParser *parser = new (XMLPlatformUtils::fgMemoryManager) 
XercesDOMParser(0,XMLPlatformUtils::fgMemoryManager);
> > parser->parse( *mbis );
>         newNode = parser->getDocument()->getDocumentElement();
>         if(!newNode){
>             delete mbis;
>             delete parser;
>             throw FrmError(xml.c_str(),"Can not parse DOM node","",ERR_MARK);
>         }
> > returnNode = getDocument()->importNode( newNode, true ); // getDocument returns our internal document > parser->resetDocumentPool();
>         delete mbis;
>         delete parser;
>     }catch(SAXException e){
>         void* msg = 
XMLString::transcode(e.getMessage(),XMLPlatformUtils::fgMemoryManager);
>         string error=(char*)msg;
>         XMLString::release((void**)&msg,XMLPlatformUtils::fgMemoryManager);
>         throw FrmError(error,"","",ERR_MARK);
>     }catch(DOMException e){
>         void* msg = 
XMLString::transcode(e.msg,XMLPlatformUtils::fgMemoryManager);
>         string error=(char*)msg;
>         XMLString::release((void**)&msg,XMLPlatformUtils::fgMemoryManager);
>         throw FrmError(error,"","",ERR_MARK);
>     }
>     if(!returnNode){
>         //throw FrmError("Can not allocate DOM Node","","",ERR_MARK);
>     }
>     return (returnNode);

------------------------------------------------------------------------
Climb to the top of the charts! Play the word scramble challenge with star power. Play now! <http://club.live.com/star_shuffle.aspx?icid=starshuffle_wlmailtextlink_jan>



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to