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 bu...@apache.org on 2002/04/03 12:41:42 UTC

DO NOT REPLY [Bug 7586] - xml4com: Xerces.DOMDocument. Create + Release = Memory leaks

DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG 
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://nagoya.apache.org/bugzilla/show_bug.cgi?id=7586>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND 
INSERTED IN THE BUG DATABASE.

http://nagoya.apache.org/bugzilla/show_bug.cgi?id=7586

xml4com: Xerces.DOMDocument. Create + Release = Memory leaks





------- Additional Comments From antony.bartlett@wallingfordsoftware.com  2002-04-03 10:41 -------
The memory leaks are caused because XMLPlatformUtils::Terminate is not called.  
I presume that Terminate is not called because there is no way of determining 
when the client program has completely finished with xml4com.

I suspect that this leak is harmless in the sense that the memory only leaks 
once.  However, all memory leaks are serious in the sense that you can't spot 
genuinely serious memory leaks if your log is cluttered with "harmless" ones.

Below is my workaround for the problem.  Because I'm using late-binding, and 
because there doesn't seem to be a COM equivalent of 
XMLPlatformUtils::Terminate available, calling Terminate isn't clean and isn't 
easy, but here's how I've done it:

#ifdef _DEBUG
        // We've finished using the XML parser.  Call it's Terminate 
        // method so that the memory that it is using doesn't look
        // like a memory leak.
        HMODULE hMod = ::GetModuleHandle(_T("xerces-c_1_7_0D"));
        FARPROC fnXmlTerminate = NULL;
        if (hMod)
        {
            fnXmlTerminate = ::GetProcAddress(
                        hMod,
                        _T("?Terminate@XMLPlatformUtils@@SAXXZ"));
        }
        if (fnXmlTerminate)
        {
            fnXmlTerminate();
        }
        else
        {
            ASSERT(false);
            // Failed to terminate XML parser, which means you will see
            // (harmless) memory leaks.  Check that the xerces module
            // named above is the same one that you are using, also check
            // that the map file entry for XMLPlatformUtils::Terminate()
            // matches the one given above.
        }
#endif // #ifdef _DEBUG

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