radada wrote:
Hi there


after searching a little bit, I found that there was some objects that were
not deleted in the other programs.
But (still that damn but...) I still get a memory leak. Weird thing : when I
delete the parser, the memory doesn't decrease. It just stays still... And
after a couple hundreds of XML files parsed, this memory leak is getting
big.
It seems that the memory increases after calling the parse method. But since
the deletion of the parser seems to have no effect on the memory, it could
come from either methods.

Here's the code for the parse method :
ElementXML* ParserXML::parse(const char* p_pcBuffer)
{
   #ifdef AFF
      cout << "ParserXML::parse()" << endl;
   #endif
// Si aucun buffer n'est passé, on renvoie NULL
   if (p_pcBuffer == NULL)
   {
      #ifdef DEBUG
         cout << "Aucun Flux à Parser!!!" << endl;
      #endif
      return NULL;
   }
char* l_pcMessage;
   // on crée un objet pour le parsing
   MemBufInputSource l_oInputSource((const XMLByte*)p_pcBuffer,
                                    strlen(p_pcBuffer),
                                    (const XMLCh*)  "ParserXML");
You cannot cast a character string constant to a UTF-16 string. This cast is incorrect.

   try
   {
      // on parse
      m_poDOMParser->parse(l_oInputSource);
      #ifdef DEBUG
         cout << "Document Parsé" << endl;
      #endif
// on libère la mémoire si besoin
      delete(m_poElementXML);
      //on crée un nouveau ElementXML avec les données du DOMDocument
      m_poElementXML = new
ElementXML(m_poDOMParser->getDocument()->getDocumentElement());
      // on retourne l'ElementXML ainsi créé
      return m_poElementXML;
Is ElementXML a single class, or a hierarchy of clases? What does its definition look like?

If you are building on Linux, I suggest you run your program under valgrind, which will detect errors and memory leaks in your program.

If you are building on Windows, I suggest you turn on the leak detection code in the C run-time library, which will give you a dump of leaks when your program exits.

Dave

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to