Re: pango memory leak
- From: "Eren S." <erencexor gmail com>
- To: nerdy <nerds_ebook1 yahoo com>, gtk-i18n-list gnome org
- Cc:
- Subject: Re: pango memory leak
- Date: Tue, 23 May 2006 06:20:29 +0300
windows 98 SE ( No WORKing :(
"""""""""""""""""""""""""""""""""
" ERROR "
Pango-ERROR **:file shape.c: line 75 (pango_shape): assertion failed: (glyphs->num_glyphs > 0)aborting...
Pango-WARNING (recursed) **.Couldn'load "MS Sans Serif 8" falling back to "Sans 8"
aborting...
[ OK ]
"""""""""""""""""""""""""""""""""
2006/5/23, nerdy <nerds_ebook1 yahoo com>:
hello all,
futher to my previous mail about a memory leak that i suspect in the
pango_font_description_set_family and pango_font_description_set_size functions, i observe that the leak exists in the latest version of pango. i am using fedora core 4 with pango version
1.8.1.
in my program i am continually increasing the size the font and this continually allocates memory. i would like to know the memory allocated for previous font size is not released/reused before allocating new memory for new font size. i also dont understand why new memory is allocated for every time the function ango_font_description_set_size is called. as far as i can see we will be resetting the font size for subsequent size requests.
please refer the program below.
#include
<gtk/gtk.h>
int size=15;
void g_exit_callback(GtkWidget
*w)
{
g_object_unref(w);
gtk_main_quit();
}
void 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)
{
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);
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;
}
thanks and regards,
nerdy
_______________________________________________
gtk-i18n-list mailing list
gtk-i18n-list gnome org
http://mail.gnome.org/mailman/listinfo/gtk-i18n-list
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]