Re: [LAD] memory leak assistance

From: hermann <brummer-@web.de>
Date: Tue Dec 29 2009 - 19:03:58 EET

Hi
gtk_widget_get_pango_context(widget) didn't need to unref, it's owned by
the widget you get it from. Unlike the context returned by
gtk_widget_create_pango_context()

 I'm use mostly style->font_desc instead.

      PangoLayout *pl;
      PangoRectangle rect;

      GtkStyle *style = gtk_widget_get_style(widget);
     
      pango_font_description_set_family(style->font_desc, "sans");
      pango_font_description_set_size(style->font_desc, 8 *
PANGO_SCALE);
     
      gtk_widget_modify_font(widget, style->font_desc);
      pl = pango_layout_new(style->font_desc);
      pango_layout_set_text(pl, "99", -1);
      pango_layout_get_pixel_extents(pl, &rect, NULL);
 
     
      g_object_unref(pl);

regards hermann

Am Mittwoch, den 30.12.2009, 01:18 +1100 schrieb Patrick Shirkey:
> Hi,
>
> I have some code in gtk2 that is leaking and I can't fix it. Over the
> past two nights I have managed to get the leak down from 200MB/minute to
> 200MB/10 minutes but I can't get rid of it completely. It's annoying
> because it increments in 200MB blocks so I have to wait for up to 10
> mins to see if it is fixed or not. I have tried valgrind but it doesn't
> really like jack and did not give me any useful output. I have traced
> the leak through normal debugging and have verified that it does not
> happen if I disable this offending code.
>
> This code is run in the widgets realize event and the event is triggered
> every 500ms.
>
>
> PangoContext *pc = gtk_widget_get_pango_context(widget);
> PangoLayout *pl;
> PangoFontDescription *pfd;
> PangoRectangle rect;
>
> pfd = pango_font_description_new();
> pango_font_description_set_family(pfd, "sans");
> pango_font_description_set_size(pfd, 8 * PANGO_SCALE);
> pango_context_set_font_description(pc, pfd);
> pl = pango_layout_new(pc);
> pango_layout_set_text(pl, "99", -1);
> pango_layout_get_pixel_extents(pl, &rect, NULL);
>
> pango_font_description_free(pfd);
> g_object_unref(pc);
>
>
> If I add another
>
> g_object_unref(pl) ;
>
>
> The app code will compile but when I run it I get this segfault:
>
> *** glibc detected *** ./src/jackeq: free(): invalid pointer:
> 0x0000000001b87a60 ***
>
>
> I can have one g_object_unref for either pl or pc without segfaulting
> but not both.
>
>
> I'm pretty sure this is the last leak I have to catch for the merged
> gtkmeter.c/gtkmeterscale.c and I can't release jackeq until it is fixed.
> Any assistance with this one is appreciated.
>
>
> Cheers.
>

_______________________________________________
Linux-audio-dev mailing list
Linux-audio-dev@email-addr-hidden
http://lists.linuxaudio.org/listinfo/linux-audio-dev
Received on Tue Dec 29 20:15:03 2009

This archive was generated by hypermail 2.1.8 : Tue Dec 29 2009 - 20:15:03 EET