why is pango_font_description_set_* functions leaking
- From: nerdy <nerds_ebook1 yahoo com>
- To: gtk <gtk-list gnome org>, gtk-app-devel <gtk-app-devel-list gnome org>, gtk-devel <gtk-devel-list gnome org>, gtk-i18n <gtk-i18n-list gnome org>
- Cc:
- Subject: why is pango_font_description_set_* functions leaking
- Date: Tue, 2 May 2006 06:03:29 -0700 (PDT)
Hello all,
I found that the functions pango_font_description_set_family and pango_font_description_set_size are leaking
memory. I am using pango version 1.4.0.
fontdesc = pango_font_description_new();
pango_font_description_set_family(fontdesc,"courier");
pango_font_description_set_size(fontdesc,size*PANGO_SCALE);
pango_font_description_free (fontdesc);
When i ran the program (pasted below) and saw the memory usage profile from top command, i see that a the
program allocates a lot of memory continuously. When i commented out the statements that i suspect are leaky,
i dont see any contiuous memory allocation. Is this behaviour typical of pango or am i missing something.
Please clarify my doubt.
Thanks in advance,
nerdy
#include <gtk/gtk.h>
int size=15;
void g_exit_callback(GtkWidget *w) { gtk_main_quit(); }
gboolean play_font(gpointer data)
{
GdkRectangle updateRect;
updateRect.x=0; updateRect.y=0;
updateRect.width=240; updateRect.height=320;
gtk_widget_draw(GTK_WIDGET(data),&updateRect);
}
void drawing_callback(GtkWidget *lWidget)
{
printf("drawing_callback\n");
PangoContext *context=NULL;
PangoLayout *layout=NULL;
PangoFontDescription *fontdesc=NULL;
context = gtk_widget_get_pango_context(lWidget);
layout = pango_layout_new(context);
fontdesc = pango_font_description_new();
// function that i suspect of leaks - one
pango_font_description_set_family(fontdesc,"courier");
// function that i suspect of leaks - two
pango_font_description_set_size(fontdesc,size*PANGO_SCALE);
pango_layout_set_font_description (layout, fontdesc);
pango_layout_set_text(layout, "middle", 6);
pango_layout_set_font_description (layout, fontdesc);
pango_layout_set_text(layout, "middle", 6);
gdk_draw_layout(lWidget->window, lWidget->style->fg_gc[GTK_STATE_NORMAL] , 5 , 10 , layout);
pango_font_description_free (fontdesc);
g_object_unref (layout);
size++;
}
int main(int argc, char **argv)
{
gtk_init(NULL,NULL);
GtkWidget *pwWindow;
GtkWidget *pWidget;
pwWindow = gtk_window_new (GTK_WINDOW_TOPLEVEL);
gtk_window_set_title (GTK_WINDOW (pwWindow), "TEST Widget");
gtk_window_set_position (GTK_WINDOW (pwWindow), GTK_WIN_POS_CENTER_ALWAYS);
g_signal_connect (G_OBJECT (pwWindow), "destroy",G_CALLBACK (g_exit_callback), NULL);
pWidget = gtk_drawing_area_new();
gtk_container_add(GTK_CONTAINER(pwWindow), pWidget);
g_signal_connect (G_OBJECT (pWidget),"expose_event", G_CALLBACK (drawing_callback), NULL);
g_timeout_add(100,(GSourceFunc)play_font,pWidget);
gtk_widget_show (pWidget);
gtk_widget_show (pwWindow);
gtk_main ();
return 0;
}
---------------------------------
Get amazing travel prices for air and hotel in one click on Yahoo! FareChase
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]