[cairo] valgrind show some leaks in simple cairo demo

Dusan Halicky dusan.halicky at gmail.com
Sun Jan 25 08:09:36 PST 2009


Hi.

Valgrind gives me some leak warnings and I don't know if it is cairo
error or I do something wrong? My cairo version is libcairo2
1.6.0-0ubuntu2 (from ubuntu 8.04)

I have following code:

#include <cairo.h>
#include <cairo-xlib.h>

int
main(int argc, char *argv[])
{
	Display * dpy = XOpenDisplay(0);
	Window win = XCreateSimpleWindow(dpy,DefaultRootWindow(dpy),0,0,320,200,0,WhitePixel(dpy,DefaultScreen(dpy)),WhitePixel(dpy,DefaultScreen(dpy)));

	cairo_surface_t * surface = cairo_xlib_surface_create(dpy, win,
DefaultVisual(dpy,DefaultScreen(dpy)), 320, 200);
	cairo_surface_destroy(surface);
	
	XDestroyWindow(dpy,win);
	XCloseDisplay(dpy);
	return 0;
}

And it display in valgrind these messages:

==8596== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 47 from 1)
==8596== malloc/free: in use at exit: 19,039 bytes in 274 blocks.
==8596== malloc/free: 978 allocs, 704 frees, 89,157 bytes allocated.
==8596== For counts of detected errors, rerun with: -v
==8596== searching for pointers to 274 not-freed blocks.
==8596== checked 236,444 bytes.
==8596==
==8596== LEAK SUMMARY:
==8596==    definitely lost: 112 bytes in 5 blocks.
==8596==      possibly lost: 0 bytes in 0 blocks.
==8596==    still reachable: 18,927 bytes in 269 blocks.
==8596==         suppressed: 0 bytes in 0 blocks.

But when I remove that 2 cairo commands, it pass valgrind test without
any warning, so I assume there is problem with cairo.

Thanks.


More information about the cairo mailing list