Hi,
The XMLString::release needs to be inside the for loop.  Every call to
XMLString::transcode will allocate memory.

Regards,
David A. Cargill
XML Parser Development
IBM Toronto Lab
(905) 413-2371, tie 969
[EMAIL PROTECTED]


                                                                       
             Marian Roselló                                          
             Bennassar                                                 
             <[EMAIL PROTECTED]>                                             To
                                       <[email protected]>     
             09/24/2007 04:43                                           cc
             AM                                                        
                                                                   Subject
                                       How to free memory after a      
             Please respond to         XMLString::transcode            
             [EMAIL PROTECTED]                                         
                 ache.org                                              
                                                                       
                                                                       
                                                                       
                                                                       




Hi,

I have a memory leak problem in my program. The memory leak seems to be
caused by the XMLString::transcode, after which I fail to release memory
correctly. This is how I use it:

    DOMNode* sysChild;
    char* sysChildName;
    String   nodeName;
     ...

     for(int i=0; i<sysElemChildren->getLength(); i++)
     {
            sysChild = sysElemChildren->item(i);
            sysChildName = XMLString::transcode(sysChild->getNodeName());
            nodeName = String(sysChildName);
            ...
    }

    XMLString::release(&sysChildName);


As you can guess from the code I need to retrieve the name of the node as a
String. I thought that with  the release memory would be released/freed,
but it does not seem to be the case.
Has any of you encounter the same problem? Could you please tell me how
could I obtain the node name as a String and release the memory to avoid
the leak?

I would really appreciate any help, I have to parse a very big XML file, so
little problems like this one become huge!!!

Thank you very much in advance.

Cheers,
Marian.



Reply via email to