XERCESC 2.7内存泄漏问题

时间:2011-01-27 08:58:37

标签: c++ xml memory-leaks xml-parsing xerces

我们正在使用XERCESC 2.7,遗憾的是网上没有太多关于这个主题的内容。

问题:使用Xerces解析时的工作流程是什么?我将展示我的工作流程,并希望我的内存泄漏将被某人发现。不幸的是,由于限制,我无法在系统上安装内存调试器。

感谢操作系统

构造

DOMBuilder * pDOMBuilder

pDOMBuilder =_pDOMImplementation->createDOMBuilder
(xercesc::DOMImplementationLS::MODE_SYNCHRONOUS, NULL);
        pDOMBuilder->setFeature(XMLUni::fgXercesUserAdoptsDOMDocument, true)
        pDOMBuilder->setFeature(xercesc::XMLUni::fgDOMNamespaces, true);
        pDOMBuilder->setFeature(xercesc::XMLUni::fgDOMValidation, true);
        pDOMBuilder->setFeature(xercesc::XMLUni::fgXercesSchema, true);
        pDOMBuilder->setFeature(xercesc::XMLUni::fgXercesSchemaFullChecking, true);
        pDOMBuilder->setFeature(xercesc::XMLUni::fgXercesValidationErrorAsFatal, true);
        pDOMBuilder->setFeature(xercesc::XMLUni::fgDOMWhitespaceInElementContent, false);
        pDOMBuilder->setFeature(xercesc::XMLUni::fgDOMDatatypeNormalization, true);
        m_pErrorHandler = new ErrorHandler();
        pDOMBuilder->setErrorHandler(m_pErrorHandler);
        pDOMBuilder->setEntityResolver(new EntityResolver(absolutePathToSchemas));

析构函数:

pDOMWriter->release();

对象的用法:

pDOMBuilder->resetDocumentPool();
pDOMBuilder->resetCachedGrammarPool(); 
m_ErrorHandler->reset();

xercesc::MemBufInputSource * pMemBufInputSource = new xercesc::MemBufInputSource((const XMLByte *)xmlStream, 
                                                                                         (unsigned int)strlen(xmlStream),
                                                                                         UnicodeString("xmlStream"));

xercesc::Wrapper4InputSource wrapper4InputSource(pMemBufInputSource);
xercesc::DOMDocument * resultDoc = m_DOMBuilder->parse(wrapper4InputSource);


resultDoc->release();

1 个答案:

答案 0 :(得分:0)

应通过调用createXXX方法释放通过release方法获取的任何Xerces DOM对象ptr。您似乎没有呼叫pDOMBuilder->release ()