You are viewing a plain text version of this content. The canonical link for it is here.
Posted to c-dev@xerces.apache.org by "pranav (JIRA)" <xe...@xml.apache.org> on 2006/11/02 08:16:17 UTC
[jira] Commented: (XERCESC-1279) Memory leak with writeToString in
DOMWriter
[ http://issues.apache.org/jira/browse/XERCESC-1279?page=comments#action_12446469 ]
pranav commented on XERCESC-1279:
---------------------------------
There is still a problem with this API: writeToString.
Memory validator reports a leak
Following is the code we've used:
SaveXMLString(const XERCES_CPP_NAMESPACE::DOMNode *const p_pDOMNode)
{
XERCES_CPP_NAMESPACE::DOMWriter *pSerializer = 0;
XERCES_CPP_NAMESPACE::XMLFormatTarget* pFormTarget = 0;
// get a serializer, an instance of DOMWriter
XMLCh tempStr[100];
XERCES_CPP_NAMESPACE::XMLString::transcode("LS", tempStr, 99);
XERCES_CPP_NAMESPACE::DOMImplementation *impl = XERCES_CPP_NAMESPACE::DOMImplementationRegistry::getDOMImplementation(tempStr);
pSerializer = ((XERCES_CPP_NAMESPACE::DOMImplementationLS*)impl)->createDOMWriter();
CString strRequest;
XMLCh* pCh = pSerializer->writeToString(*p_pDOMNode);
char *msg = XERCES_CPP_NAMESPACE::XMLString::transcode(pCh);
strRequest= msg;
XERCES_CPP_NAMESPACE::XMLString::release(&msg);
XERCES_CPP_NAMESPACE::XMLString::release(&pCh);
}
Memory validation tools indicate a leak in the writeToString implementation of DomWriterImpl.I'll attach a file that shows the snapshot of the leak shown.
> Memory leak with writeToString in DOMWriter
> -------------------------------------------
>
> Key: XERCESC-1279
> URL: http://issues.apache.org/jira/browse/XERCESC-1279
> Project: Xerces-C++
> Issue Type: Bug
> Affects Versions: 2.5.0
> Reporter: Dee
> Priority: Critical
>
> Hi All,
> I have a very critical issue and we a re trying to implement this in our mission critical application..
> I'm trying to use writeToString in DOMWriter using the function GetXmlString below ---->
> I am getting a memory leak proportionate to the size of document been serialized.
> I'm unable to free up the memory allocated .
> Is it something else we need to do ensure that the leak is closed..
> Kindly suggest..
> std::string GetXmlString(DOMNode *pNode)
> {
> std::string sXML = "";
> try
> {
> DOMImplementation* impl = DOMImplementationRegistry::getDOMImplementation(X("Core"));
> // get the XML string out of the DOM
> DOMWriter *theSerializer = impl->createDOMWriter();
> XMLCh *xXml = theSerializer->writeToString(*pNode);
> char *pChar = XMLString::transcode(xXml);
> sXML = pChar;
> XMLString::release(&pChar);
> XMLString::release(&xXml);
> delete theSerializer;
> // delete impl;
> // theSerializer->release();
> //delete theSerializer;
> }
> catch(const XMLException& toCatch)
> {
> char *pMsg = XMLString::transcode(toCatch.getMessage());
> XMLString::release(&pMsg);
>
> }
> return sXML;
> }
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
---------------------------------------------------------------------
To unsubscribe, e-mail: c-dev-unsubscribe@xerces.apache.org
For additional commands, e-mail: c-dev-help@xerces.apache.org