[cairo] Possible Memory Leak Using Glitz Surfaces

Charles Tuckey ctuckey at verano.com
Wed Jul 21 12:41:30 PDT 2004


Thanks for the patch David. I applied the patch and reran the test with 
the same results. In addition, I ran the test on a machine that had the 
Mesa GL libraries and there was no memory leak.

Is there anyone else out there that can try this program on a system 
that has the NVidia driver installed and let me know what results you get?

It seems funny that both the NVidia and XiG libraries leak but the Mesa 
one doesn't. It also seems strange that it appears no one has run into 
this problem before using other applications. BTW, the NVidia leak is 
not the known rmap bug; we have checked for that.

I will continue to pursue this problem (I have no choice!) and will let 
you know what I discover. If anyone has any hints on what I should be 
looking for, I would very much appreciate hearing from you.

charlie

David Reveman wrote:
> On Tue, 2004-07-20 at 17:27 -0600, Charles Tuckey wrote:
> 
>>Hi,
>>
>>I have found an extremely large memory leak that occurs when using cairo 
>>with glitz surfaces. I have attached a very simple program that 
>>demonstrates the leak. I've run the program (and demonstrated the leak) 
>>against two different video cards: one is an NVidia card using the 
>>latest NVidia driver and the other is a Matrox card using an Xi Graphics 
>>driver. The NVidia card is on a RedHat 9 system and the Matrox card is 
>>on a Redhat Enterprise 2.1 system.
>>
>>The leak does not occur using pixman surfaces. Also, if the glitz 
>>surfaces are destroyed after each use, instead of using the same glitz 
>>surface all the time, the leak slows down by several orders of magnitude 
>>but is still quite noticeable.
>>
>>I used valgrind to try and track down the source of the leak on the 
>>NVidia system. It does not appear to be in either cairo or glitz but in 
>>the GL driver supplied by NVidia for the video card. This makes me 
>>wonder if it is in fact a leak, or if I am using glitz incorrectly.
>>
>>Any help or advice on this issue would be appreciated.
> 
> 
> ok, I looked at your test program and there are some minor problems.
> 
> You shouldn't use XCreateSimpleWindow to create windows for GLX
> rendering. You must first find a valid visual and then use that visual
> to create the window. glitz_glx_find_standard_format will find a valid
> visual for you, just use glitz_glx_get_visual_info_from_format to get a
> pointer to a XVisualInfo structure which you can use to create the
> window. I've attached a patch for this.
> 
> It's not impossible that this is somehow related to your memory leak.
> Running your test program with software mesa shows no memory leak.
>  
> -David
> 
> 
> ------------------------------------------------------------------------
> 
> --- memleak_test.c	2004-07-21 01:24:47.000000000 +0200
> +++ ../glitz_memory_leak.fix/memleak_test.c	2004-07-21 15:00:21.571839096 +0200
> @@ -10,6 +10,8 @@
>      Window win;
>      int scr;
>      glitz_format_t *format;
> +    XVisualInfo *vinfo;
> +    XSetWindowAttributes xswa;
>  
>      int use_glitz = 1;
>      int destroy_gl_surface = 0;
> @@ -17,11 +19,21 @@
>  
>          dpy = XOpenDisplay (0);
>          scr = DefaultScreen (dpy);
> -        win = XCreateSimpleWindow (dpy, DefaultRootWindow(dpy), 0, 0, 400, 400, 0, 0, 0);
>  
>          format = glitz_glx_find_standard_format (dpy, scr,
>                                                   GLITZ_FORMAT_OPTION_ONSCREEN_MASK,
>                                                   GLITZ_STANDARD_RGB24);
> +        vinfo = glitz_glx_get_visual_info_from_format (dpy, scr, format);
> +
> +        xswa.colormap = XCreateColormap (dpy, RootWindow (dpy, scr),
> +                                         vinfo->visual, AllocNone);
> +  
> +        win = XCreateWindow (dpy, RootWindow (dpy, scr), 
> +                             0, 0, 400, 400,
> +                             0, vinfo->depth, InputOutput,
> +                             vinfo->visual, CWColormap, &xswa);
> +
> +        XFree (vinfo);
>                                                               
>          sf = glitz_glx_surface_create_for_window (dpy, scr, format, win);
>  
> @@ -52,6 +64,7 @@
>  
>      if ( use_glitz ) {
>          glitz_surface_destroy ((glitz_surface_t *)sf);
> +        XDestroyWindow (dpy, win);
>      } else {
>          cairo_surface_destroy ((cairo_surface_t *)sf);
>          XDestroyWindow (dpy, win);
> 
> 
> ------------------------------------------------------------------------
> 
> _______________________________________________
> cairo mailing list
> cairo at cairographics.org
> http://cairographics.org/cgi-bin/mailman/listinfo/cairo

-- 
Charles Tuckey, MSc.
Software Developer
Verano, Inc.
403.299.4765

  © Copyright 2004 Verano Inc. owns copyright content of this document 
and all attachments unless otherwise indicated. All rights reserved. 
Users of Verano Inc. software and tools associated with the software 
such as sales & marketing collateral, presentations, user manuals, 
training documentation etc. may not republish nor reproduce in whole or 
in part the information, in any form or by any means, in any manner 
whatsoever without the prior written permission of Verano Inc., and any 
such unauthorized use constitutes copyright infringement. An 
acknowledgement of the source must be included whenever Verano Inc. 
material is copied or published. If you require further information on a 
permitted use or license to reproduce or republish any material, address 
your inquiry to Verano Inc.Suite 120, 575 West Street, Mansfield, 
Massachusetts, 02048-1164. Any infringement of Verano Inc. rights  will 
result in appropriate legal action. Verano Inc. disclaims any and all 
liability for any consequences which may result from any unauthorized 
reproduction or use of this Work whatsoever.





More information about the cairo mailing list