Hi Vladimir and all,

One somewhat tangential thing that I think bears emphasizing (Xerces
already has FAQ's to this effect) is that placing lines like

        XercesDOMSupport theDOMSupport;
        XercesParserLiaison theParserLiaison;

at the same scope as calls to XMLPlatformUtils::Initialize() is probably
not a good idea.  If you actually had a call to XMLPlatformUtils::Terminate
() in the function, it would destroy the object that allocated any
Xerces-owned objects that either of these classes allocated; thus, when
these go out of scope when the function returns, their implicit destruction
is liable to make your program seg fault.  I don't know whether
XercesDOMSupport or XercesParserLiaison actually create Xerces objects at
construction time (or try and destroy such at construction time), but I'd
bet Xalan developers wouldn't be willing to guarantee for all time that
this won't happen.

Cheers,
Neil
Neil Graham
XML Parser Development
IBM Toronto Lab
Phone:  905-413-3519, T/L 969-3519
E-mail:  [EMAIL PROTECTED]




|---------+---------------------------->
|         |           Vladimir Marek   |
|         |           <[EMAIL PROTECTED]|
|         |           cz>              |
|         |                            |
|         |           08/06/2003 05:03 |
|         |           AM               |
|         |           Please respond to|
|         |           xalan-dev        |
|         |                            |
|---------+---------------------------->
  
>---------------------------------------------------------------------------------------------------------------------------------------------|
  |                                                                                    
                                                         |
  |       To:       [EMAIL PROTECTED]                                                  
                                                  |
  |       cc:                                                                          
                                                         |
  |       Subject:  XercesDOMWrapperParsedSource memory problem                        
                                                         |
  |                                                                                    
                                                         |
  |                                                                                    
                                                         |
  
>---------------------------------------------------------------------------------------------------------------------------------------------|



Hello,

I found that my program is leaking, and after some investigation I found
this minimal testcase:

-- CUT --
using namespace std;

#include <iostream>

#include <xercesc/util/PlatformUtils.hpp>
#include <xercesc/dom/DOM.hpp>

#include <XercesParserLiaison/XercesDOMSupport.hpp>
#include <XercesParserLiaison/XercesParserLiaison.hpp>
#include <XalanTransformer/XercesDOMWrapperParsedSource.hpp>

XALAN_CPP_NAMESPACE_USE
XERCES_CPP_NAMESPACE_USE

void process(
                DOMDocument *input,
                XercesParserLiaison &theParserLiaison,
                XercesDOMSupport &theDOMSupport)
{

        XercesDOMWrapperParsedSource parsedSource
                (input, theParserLiaison, theDOMSupport);

}

int main (int argc, char **argv) {
        XMLPlatformUtils::Initialize();

        DOMImplementation* impl =
                DOMImplementationRegistry::getDOMImplementation
                        (XMLString::transcode("Core"));

        DOMDocument* doc =
                impl->createDocument( 0, XMLString::transcode("root"),
0);

        XercesDOMSupport theDOMSupport;
        XercesParserLiaison theParserLiaison;

        while (1) {
                process (doc, theParserLiaison, theDOMSupport);
        }

        return 0;
}
-- CUT --

Problem is in the function 'process', each construction of
XercesDOMWrapperParsedSource takes some memory, but it's never freed.
Probably I'm missing something, please could you help me a bit ?

PS: I'm not sure if I am at the correct list, if not, would you be so
kind and redirect me ?

Thank you
--
             Vladim�r Marek



Reply via email to