Re: possible memleak with pangoft2?

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

 



Hello, John ;)

You're leaking fontmap object. I dont know when fontmap object gets all extra references (just have no time to look inside), but its natural to have only one instance of it per app.
static void
test( const char *text, const char *font ) {
PangoFontMap *fontmap;
PangoContext *context;
PangoLayout *layout;
PangoFontDescription *font_description;
PangoRectangle logical_rect;


fontmap = pango_ft2_font_map_new();
context = pango_ft2_font_map_create_context( PANGO_FT2_FONT_MAP( fontmap ) );


        layout = pango_layout_new( context );

        font_description = pango_font_description_from_string( font );
        pango_layout_set_font_description( layout, font_description );
        pango_font_description_free( font_description );

        pango_layout_set_markup( layout, text, -1 );

        /* Comment this line out and the leak stops.
         */
        pango_layout_get_extents( layout, NULL, &logical_rect );

g_print("layout: %d\n", G_OBJECT(layout)->ref_count);
g_print("context: %d\n", G_OBJECT(context)->ref_count);
g_print("fontmap: %d\n---\n", G_OBJECT(fontmap)->ref_count);
g_object_unref( layout );
g_print("context: %d\n", G_OBJECT(context)->ref_count);
g_print("fonmap: %d\n---\n", G_OBJECT(fontmap)->ref_count);
g_object_unref( context );
g_print("fontmap: %d\n---\n", G_OBJECT(fontmap)->ref_count);
g_object_unref( fontmap );
g_print("fontmap: %d (%s)\n---\n", G_OBJECT(fontmap)->ref_count, G_IS_OBJECT(fontmap)?"valid":"invalid");
}
[skipped]

Look at output: I have 19 references and valid fontmap object after all unrefs.

	Olexiy

_______________________________________________

gtk-list@xxxxxxxxx
http://mail.gnome.org/mailman/listinfo/gtk-list

[Index of Archives]     [Touch Screen Library]     [GIMP Users]     [Gnome]     [KDE]     [Yosemite News]     [Steve's Art]

  Powered by Linux