Re: Memory leak

On Thu, 30 Nov 2000, Nadav Armoni wrote:

> I'm using Tidy to parse an HTML file and to build my own tree
> from the Tidy tree. When I run tidy in a loop on the same file (
> this file is attaced to this Email ) all night without writing
> back to the file ( this mean it was the same HTML file every
> time ) I noticed a memory leak. When I looked into the code of
> the Tidy, I found out that althogu Tidy report he is discarding
> an unexpected tag ( in this case </font>) he didn't free the
> node of that tag.
> 
> So in function ParseRow ( in file: parser.c line:1752) I added
> this line:
> 
> FreeNode( node );
> 
> In order to free this node, and it worked for that perticular page.
> 
> When I tested other pages, I found out the same probalm but in
> diffrent places in the code, So I checked a bit further and
> found out that tidy can discarde an unexpected tags in 68
> locations (all of them in file: parser.c), but in 15 places Tidy
> is not freeing the node after that.
> 
> So my qustion is, should I add:
> 	FreeNode( node );
> to all of the 15 places, or maybe just to part of them?

It shouldn't do, provided it is followed by a "continue" to
get the next node. Thanks for spotting this. I will search
the code for the other such cases.

Regards,

-- Dave Raggett <dsr@w3.org> or <dave.raggett@openwave.com>
W3C Visiting Fellow, see http://www.w3.org/People/Raggett 
tel/fax: +44 122 578 3011 (or 2521) +44 771 213 7629 (mobile)

Received on Sunday, 3 December 2000 21:04:18 UTC