Hi All,

In the process of building the Xerces-P-2.6 release, I ran across a
bizarre memory leak. After trying everything I could think of, I
tested a straight C++ example and it seems to leak like a seive.

I have read the memory management code in the programming docs about
12 times, and even when I to what it says, I get the leak.

According to the docs:

   Users must call the release() function when finished using any
   objects that were created by the DOMImplementation::createXXXX
   (e.g. DOMBuilder, DOMWriter, DOMDocument, DOMDocumentType).

So here is the code:

    XMLCh xfoo[] = {chLatin_f, chLatin_o, chLatin_o, chNull};
    DOMImplementation* impl =  
DOMImplementationRegistry::getDOMImplementation(X("Core"));
    while (1) 
    {
        try
        {
            DOMDocumentType* dt = impl->createDocumentType(xfoo,xfoo,xfoo);
            dt->release();                   
        }
        catch (...)
        {
            XERCES_STD_QUALIFIER cerr << "An error occurred creating the 
document" << XERCES_STD_QUALIFIER endl;
            errorCode = 3;
        }
    }

But this leaks.

Replacing 'dt->release()' with 'delete dt' has no affect.

The docs also say:

  When a DOMDocumentType has been inserted into a DOMDocument and thus
  has a owner, it will then be released automatically when its owner
  document is released. 

So I added:

           DOMDocument* doc = impl->createDocument(0,xfoo,dt); 
           doc->release();

in place of the 'dt->release()' but this had no affect.

However, removing the creation of the DocumentType and calling:

           DOMDocument* doc = impl->createDocument(0,xfoo,0); 
           doc->release();

Does *not* leak.

Is this a real leak or am I missing something? How is one supposed to
deal with DOMDocumentType memory?

Thanks,
jas.

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to