Hi Holger,

If you put the XercesParserLiaison instance into the for loop, or call
XercesParserLiaions::reset() after each transformation, you'll discover
that memory usage will stay constant.  This is a bug in the destructor of
XercesDOMWrapperParsedSource which will be fixed in the next release.  If
you want to patch and rebuild your local copy, here's the diff:

   cvs diff XercesDOMWrapperParsedSource.cpp (in directory V:
   \xml-xalan\c\src\XalanTransformer\)
   Index: XercesDOMWrapperParsedSource.cpp
   ===================================================================
   RCS file:
   /home/cvspublic/xml-xalan/c/src/XalanTransformer/XercesDOMWrapperParsedSource.cpp,v
   retrieving revision 1.3
   diff -r1.3 XercesDOMWrapperParsedSource.cpp
   119a120
   >  m_parserLiaison.destroyDocument(m_parsedSource);


> Ups, I have found a mail of yours in xalan-dev where you write
>
> >"If  you use the str() member function of ostrstream, you must either
call
> >ostrstream::freeze() with a value of false, or delete the pointer
yourself."
>
> So I thought I have to delete the memory.

Yes, but in this case, you're only calling str() to delete the pointer.
Since you've not called str() prior to that, there's no need to do the
delete yourself.

Dave



                                                                                       
                                                           
                      Holger Floerke                                                   
                                                           
                      <floerke@doctron         To:      [EMAIL PROTECTED]       
                                                           
                      ic.de>                   cc:      (bcc: David N 
Bertoni/Cambridge/IBM)                                                      
                                               Subject: Re: Xalan-C++ - 
XercesDOMWrapperParsedSource consuming memory                             
                      03/17/2002 10:43                                                 
                                                           
                      PM                                                               
                                                           
                      Please respond                                                   
                                                           
                      to xalan-dev                                                     
                                                           
                                                                                       
                                                           
                                                                                       
                                                           




>You should _not_ call XalanTransformer::destroyParsedSource() with an
>instance you create yourself on the stack.  The documentation is explicit
>about this.
But what I have to do? Doing a simple

for(;;)
{
     XercesDOMWrapperParsedSource
         oSource (oDocument,
                  oParserLiaison,
                  oDOMSupport,
                  XalanDOMString("FormatterInputSource"));

     int nResult =
       oTransformer.transform(oSource,
                              oStylesheet,
                              oResult);

...
}

leads to growing memory also. I tried to put the Transformer instance into
to for()-scope, too. Nothing changed.

>Also, you don't need to do this:
>
>    delete [] oOStream.str();
>
>since you haven't called ostrstream::str().
Ups, I have found a mail of yours in xalan-dev where you write

"
>If  you use the str() member function of ostrstream, you must either call
>ostrstream::freeze() with a value of false, or delete the pointer
yourself:
"

So I thought I have to delete the memory.

>I don't know if there's a memory leak issue.  We haven't found one, but
>I'll try to do some testing with your code.
That would be very fine. If I can help you, feel free to contact me. In the

meantime I will serialize the Xerces-DOM to a stream :^)

HolgeR








Reply via email to