hichem wrote:
I am having a memory leak with the following code. I am using xerce 2.7.
I am getting a memory leak proportionate to the size of document been
serialized. Please let me know if I am dong something wrong. RWCString
XMLHelper::serializeDocument(DOMDocument *doc) { DOMWriter* writer = 0;
XMLCh* result = 0; XMLPlatformUtils::Initialize(); if (!doc) return
RWCString(); *writer =
((DOMImplementationLS*)m_impl)->createDOMWriter(); result =
writer->writeToString(*(DOMNode*)doc->getDocumentElement()); RWCString
tempStr = XMLString::transcode(result);* XMLString::release(&result);
writer->release(); XMLPlatformUtils::Terminate(); return result; } }
It's probably the result of the call to XMLString::transcode(result),
although it's hard to say, since I don't know what "RWCString" is.
try:
char* buf = XMLString::transcode(result);
RWCString tempStr(buf);
XMLString::release(&buf);
Also, it seems very broken that you free "result" then return that.
Perhaps you mean "return tempStr;" instead?
Dave
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]