But when I run the application, I always end up with memory leaks. I've tried calling the Clear() method. Heck, I've tried recursively stepping through the DOM to delete each node manually. Still, memory leaks. What gives? Is there a copy being made somewhere that I don't know about?
NOTE: If I allocate XiXmlDocument on the stack, I get no memory leaks. In other words, this code causes no leaks:
I'm using TinyXml in a DLL. Since I make multiple calls to the same XML, I am using a static pointer. The first call to my DLL causes this:
s_pXmlDoc = new TiXmlDocument();
s_pXmlDoc->Parse( lpszXml, NULL, TIXML_ENCODING_UTF8 );
When the DLL detaches or when a new XML loaded, I do this to clean up my mess:
if( s_pXmlDoc )
{
delete s_pXmlDoc;
s_pXmlDoc = NULL;
}
But when I run the application, I always end up with memory leaks. I've tried calling the Clear() method. Heck, I've tried recursively stepping through the DOM to delete each node manually. Still, memory leaks. What gives? Is there a copy being made somewhere that I don't know about?
NOTE: If I allocate XiXmlDocument on the stack, I get no memory leaks. In other words, this code causes no leaks:
TiXmlDocument xmlDoc;
xmlDoc.Parse( lpszXml, NULL, TIXML_ENCODING_UTF8 );
But this doesn't help me because I need to persist the XML across multiple DLL function calls.