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


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 );
        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);


_________________________________________________________________
Need to know the score, the latest news, or you need your HotmailĀ®-get your 
"fix".
http://www.msnmobilefix.com/Default.aspx

Reply via email to