As far as I can tell it is still allocated.
I am using vld (Visual Leak Detector) which in my experience usually don't 
report any false leaks.
If I comment out the deletion of the parser I get 154 memory leaks.
Also commenting out XMLPlatformUtils::Terminate() gives 3410 leaks.

Peter


-----Original Message-----
From: Alberto Massari [mailto:[email protected]] 
Sent: den 1 oktober 2010 13:17
To: [email protected]
Subject: Re: Memory leak in DOMText::getWholeText?

  The memory is owned by the DOMDocument, which is owned by the parser 
(as you used getDocument instead of adoptDocument to obtain it).
Can you check if the memory is still allocated after the "delete 
parser;" statement?

Alberto

On 10/1/2010 11:35 AM, Peter Gerell wrote:
> Hi
> I have a problem with memory leaks in my application.
> The memory is allocated from within DOMTextImpl::getWholeText() using
> GetDOMNodeMemoryManager->allocate().
>
> As far as I can tell this memory should be owned by the implementation and 
> released automatically.
>
> Is this a bug or am I doing something wrong?
> I get one leaked object when running the following example.
>
> Best Regards Peter
>
> My input looks like this
> <?xml version="1.0" encoding='utf-8' ?>
> <root>Foo</root>
>
>
> My code looks like this:
>
> int main() {
>    std::string msg;
>    XercesDOMParser* parser = 0;
>    DOMImplementation* impl = 0;
>    try {
>      XMLPlatformUtils::Initialize();
>
>      XMLCh* t = XMLString::transcode("XML 1.0 Traversal 2.0");
>      impl = DOMImplementationRegistry::getDOMImplementation(t);
>      XMLString::release(&t);
>
>      parser = new XercesDOMParser();
>
>      parser->setValidationScheme(XercesDOMParser::Val_Never);
>      parser->setDoNamespaces(false);
>      parser->setDoSchema(false);
>      parser->setLoadExternalDTD(false);
>
>      parser->parse("a.xml");
>      DOMDocument* doc = parser->getDocument();
>
>      DOMElement* root = doc->getDocumentElement();
>
>      char *c = XMLString::transcode(root->getTagName());
>      std::cout<<  c<<  std::endl;
>      XMLString::release(&c);
>
>      DOMNodeList* childList = root->getChildNodes();
>      const XMLSize_t childCount = childList->getLength();
>      assert(childCount==1);
>      DOMNode* node = childList->item(0);
>      assert(node);
>      assert(node->getNodeType() == DOMNode::TEXT_NODE);
>
>      const XMLCh* tempStr = static_cast<DOMText*>(node)->getWholeText(); // 
> This object is leaked
>      c = XMLString::transcode(tempStr);
>      std::cout<<  "Text = "<<  c<<  std::endl;
>      XMLString::release(&c);
>    } catch (const XMLException&  xexp) {
>      char * message = XMLString::transcode(xexp.getMessage());
>      msg = std::string(message);
>      XMLString::release(&message);
>    } catch (const DOMException&  dexp) {
>      char * message = XMLString::transcode(dexp.getMessage());
>      msg = std::string(message);
>      XMLString::release(&message);
>    }
>    std::cout<<  msg;
>    delete parser;
>    XMLPlatformUtils::Terminate();
>    return 0;
> }
>
> .
>



Reply via email to