[xml] htmlParseDoc leak ?




Hello,

I use the libxml2 (2.7.2)

I have some problems with the HTML parser ("htmlParseDoc" subroutine)
It seems htmlParseDoc leak. (???)
An other point is, if I remove the "DOCTYPE" of my html file, the memory leak decreases. (?)


--- html code 1 (with the "DOCTYPE data")
Valgrind returns the following memory leak

==8857== LEAK SUMMARY:
==8857==    definitely lost: 155,437 bytes in 3,980 blocks.
==8857==    indirectly lost: 13,772,942 bytes in 28,961 blocks.
==8857==      possibly lost: 24,576 bytes in 2 blocks.
==8857==    still reachable: 3,266 bytes in 58 blocks.
==8857==         suppressed: 0 bytes in 0 blocks.


--- html code 2 (same as "html code 1" but without the "DOCTYPE data")
Valgrind returns the following memory leak  :

 LEAK SUMMARY:
==7633==    definitely lost: 122,809 bytes in 1,972 blocks.
==7633==    indirectly lost: 1,443,728 bytes in 25,003 blocks.
==7633==      possibly lost: 0 bytes in 0 blocks.
==7633==    still reachable: 1,562 bytes in 26 blocks.
==7633==         suppressed: 0 bytes in 0 blocks.

in this case, the "indirectly lost" is up to 10 times lower ...



here are the "html codes"
--- "html code 1"
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html>
<head><title>Un essai</title>   
</head>
<body>
<DIV id="cm6">See all</DIV>
</body>
</html>



--- and "html code2"

<html>
<head><title>Un essai</title>   
</head>
<body>
<DIV id="cm6">See all</DIV>
</body>
</html>


the source code is :
(there is a loop for memory leak check purpose)
---
    xmlInitParser();
   
    for (int i=0; i<1000; i++)
    {    
      htmlDocPtr l_doc = htmlParseDoc( (xmlChar*)l_content, "UTF-8") ;
    
      if ( l_doc != NULL )
      {
        xmlFree(l_doc);
      }

    }

    xmlCleanupParser();
    xmlMemoryDump();


Does anyone have an idea ?


Stéphane Rubino




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]