List Info

Thread: libxml memory leaks




libxml memory leaks
user name
2007-01-18 12:30:15
I am using libxml2-2.6.26, cross-compiled for an ARM
platform.

I am seeing very severe memory leaks - on the order of 40K
per 
invocation of xmlXPathNewContext (if I read valgrind
correctly...)

I've gone through the code, and I am using

xmlFree(xpathCtx);

paired with every invocation of xmlXPathNewContext.

I can't help but think that I am doing something seriously
wrong....

I am only using three functions that allocate memory in the
following order:

doc = xmlReadFile("file");
xpathCtx = xmlXPathNewContext(doc);
xpathObj =
xmlXPathEvalExpression("expr",xpathCtx);

Is there some special way I need to free these pointers:

I am freeing them in the following order:

xmlFree(xpathCtx);
xmlFree(xpathObj);
xmlFreeDoc(doc);

What am I missing?

(I can provide more info if someone can tell me what options
to throw at 
valgrind...)

--Yan
_______________________________________________
xml mailing list, project page  http://xmlsoft.org/
xmlgnome.org
http://mai
l.gnome.org/mailman/listinfo/xml

Re: libxml memory leaks
user name
2007-01-18 12:34:36
Yan Seiner wrote:
> there some special way I need to free these pointers:
>
> I am freeing them in the following order:
>
> xmlFree(xpathCtx);
> xmlFree(xpathObj);
> xmlFreeDoc(doc);
>   
Sorry!

That's actually

xmlFree(xpathObj);

xmlFree(xpathCtx);

xmlFreeDoc(doc);


_______________________________________________
xml mailing list, project page  http://xmlsoft.org/
xmlgnome.org
http://mai
l.gnome.org/mailman/listinfo/xml

Re: libxml memory leaks
user name
2007-01-18 12:36:25
* Yan Seiner wrote:
>I am using libxml2-2.6.26, cross-compiled for an ARM
platform.
>
>I am seeing very severe memory leaks - on the order of
40K per 
>invocation of xmlXPathNewContext (if I read valgrind
correctly...)
>
>I've gone through the code, and I am using
>
>xmlFree(xpathCtx);
>
>paired with every invocation of xmlXPathNewContext.

You have to use the proper deallocation routines,
xmlXPathFreeContext,
xmlXPathFreeObject, and xmlFreeDoc in your case.
-- 
Björn Höhrmann · mailto:bjoernhoehrmann.de · http://bjoern.hoehrmann.de

Weinh. Str. 22 · Telefon: +49(0)621/4309674 · http://www.bjoernsworld.de

68309 Mannheim · PGP Pub. KeyID: 0xA4357E78 · http://www.websitedev.de/ 
_______________________________________________
xml mailing list, project page  http://xmlsoft.org/
xmlgnome.org
http://mai
l.gnome.org/mailman/listinfo/xml

[1-3]

about | contact  Other archives ( Real Estate discussion Medical topics )