XERCESC 2.7 内存泄漏问题

发布于 2024-10-14 16:14:23 字数 1974 浏览 7 评论 0原文

我们正在使用 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

绮筵 2024-10-21 16:14:23

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

Anything Xerces DOM object ptr acquired via a createXXX method should be released by calling its release method. You don't appear to be calling pDOMBuilder->release ().

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文