xerces-c-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Alberto Massari <amass...@progress.com>
Subject Re: Memory Trouble in DOMNode::getTextContent
Date Fri, 05 Mar 2004 15:51:29 GMT
At 16.41 05/03/2004 +0100, Patrick Wicki wrote:
>I still have memory trouble using DOMNode::getTextContent with XERCES Ver. 
>The following loop I created runs about 1400 times on my machine, and 
>shortly after that it crashes! Does anybody see what causes the leak!?

It's not a leak; getTextContent() will allocate the returned buffer from 
the memory pool held by the DOMDocument. That memory will be released when 
you release the DOMDocument itself, but if you keep invoking it, your app 
will crash because of an uncaught "out of memory" exception.
The only suggestion I can give you is to avoid using getTextContent when 
you know that the element only contains a single text node, and use 
getNodeValue() on that child node.


>(I always ask for the same tag ("aufopn_1") to make it as easy as possible!)
>Regards and thanks for the hint before
>void get_sql_stat_from_xml_test()
>   DOMNodeList* sql_statements;
>   //Allocate XMLCh for Tag
>   static XMLCh* pOutputEncoding[1];
>   pOutputEncoding[0] = XMLString::transcode("aufopn_1");
>   //1486 times ok, 1487 time it crashes!
>   for(int i=0; i<1486; i++){
>                 sql_statements = 
> get_xml_document()->getElementsByTagName(pOutputEncoding[0]);
>                 char* 
> pStr=XMLString::transcode(sql_statements->item(0)->getTextContent());
>         XMLString::release(&pStr);
>   }
>    //Release
>    XMLString::release(&pOutputEncoding[0]);
>To unsubscribe, e-mail: xerces-c-dev-unsubscribe@xml.apache.org
>For additional commands, e-mail: xerces-c-dev-help@xml.apache.org

To unsubscribe, e-mail: xerces-c-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-c-dev-help@xml.apache.org

View raw message