Re: memory leak in PangoLayout?



On 05/07/2011 12:00 AM, Bill C wrote:
On 06/05/11 17:28, Olivier Sessink wrote:
Hi all,

valgrind reports a memory leak in the following code:

gint
widget_get_string_size(GtkWidget * widget, gchar * string)
{
PangoLayout *layout;
gint retval = -1;
layout = gtk_widget_create_pango_layout(widget, string);
if (layout != NULL) {
pango_layout_get_pixel_size(layout, &retval, NULL);
g_object_unref(G_OBJECT(layout));
}
return retval;
}

but it seems 100% perfect to me. Why would this leak memory??

anybody a clue?

Just a thought, GTK could be using slab memory allocation, so the memory
is still allocate to GTK, but can be used later by gtk as required,
without inefficiencies caused by memory fragmentation.

I'm running valgrind with G_SLICE=always-malloc to avoid this false positive.

I have not seriously programmed with GTK for about a year and am not
saying that GTK has no leaks, but IMHO, nearly all the complaints about
GTK leaking memory are due to the inexperience of the posters, rather
than GTK itself.

that's why I posted the code

However if there is a valid fault, then the track record states it will
be fixed fast.

Also are you using GTK2+ or GTK3 and what version.

this is on both GTK 2.20.1 (Ubuntu 10.04) and GTK 2.24.2 (Fedora 14).

regards,
        Olivier



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]