XERCESC 2.7 内存泄漏问题
我们正在使用 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();
We are using XERCESC 2.7 unfortunately there is not too much about this topic on the web.
Question: What is the Workflow when parsing with Xerces? I will show the workflow i have and hopefully my memory leak will be spottet by somebody. Unfortunately i cannot install a memory debugger on the system due to restrictions.
Thanks OS
Constructor:
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));
Destructor:
pDOMWriter->release();
Usage of the Object:
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();
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
通过
createXXX
方法获取的任何 Xerces DOM 对象 ptr 都应该通过调用其release
方法来释放。您似乎没有调用pDOMBuilder->release ()
。Anything Xerces DOM object ptr acquired via a
createXXX
method should be released by calling itsrelease
method. You don't appear to be callingpDOMBuilder->release ()
.