2008/5/14 Harinandan S <harinandans@xxxxxxxxx>: > When i ran it under valgrind with G_SLICE=always-malloc G_DEBUG=gc_friendly\ > valgrind --tool=memcheck --leak-check=yes ./a.out &>leak.log > > I got these leaks reported. Those are harmless singleton objects (I think), they are not leaks. > My main concern is running this on DirectFB platform. Its accumulating > memory completely. I see no decrease in memory usage when second > window is destroyed. Is that valgrind output for the directfb backend? As I'm sure you know, apps never (almost never) shrink. If you open/close/open/close/open/close and see a steady increase in memuse that does sound like a leak. But that's something valgrind should be able to help you with. Here's a version of your program that uses a timeout to pop the popup up and down repeatedly. I tried it on windows and linux and saw no steady increase in memuse, as least as reported by the pretty useless task manager. I don't have a directfb install to test it on, sadly. John
/* compile with * gcc try39.c `pkg-config gtk+-2.0 --cflags --libs` */ #include <gtk/gtk.h> void on_close_clicked (GtkButton * button, gpointer user_data) { GtkWidget *win = GTK_WIDGET (user_data); gtk_widget_destroy (win); } static gboolean on_close_timeout (gpointer user_data) { GtkWidget *win = GTK_WIDGET (user_data); gtk_widget_destroy (win); return FALSE; } GtkWidget * create_window2 (GtkWidget * parent, gboolean self_close) { GtkWidget *win; GtkWidget *align; GtkWidget *but; win = gtk_window_new (GTK_WINDOW_POPUP); gtk_window_set_default_size (GTK_WINDOW (win), 100, 100); gtk_window_set_transient_for (GTK_WINDOW (win), GTK_WINDOW (parent)); gtk_window_set_position (GTK_WINDOW (win), GTK_WIN_POS_CENTER_ON_PARENT); align = gtk_alignment_new (0.5, 0.5, 0, 0); gtk_container_add (GTK_CONTAINER (win), align); gtk_widget_show (align); but = gtk_button_new_from_stock (GTK_STOCK_CLOSE); gtk_container_add (GTK_CONTAINER (align), but); if (self_close) g_timeout_add (50, (GSourceFunc) on_close_timeout, win); else g_signal_connect (but, "clicked", G_CALLBACK (on_close_clicked), win); gtk_widget_show (but); return win; } void on_open_clicked (GtkButton * button, gpointer user_data) { GtkWidget *win = GTK_WIDGET (user_data); GtkWidget *window2; window2 = create_window2 (win, FALSE); gtk_widget_show (window2); } static gboolean on_open_timeout (gpointer user_data) { GtkWidget *win = GTK_WIDGET (user_data); GtkWidget *window2; window2 = create_window2 (win, TRUE); gtk_widget_show (window2); return TRUE; } GtkWidget * create_window1 (void) { GtkWidget *win; GtkWidget *but; GtkWidget *align; GtkWidget *hbox; win = gtk_window_new (GTK_WINDOW_TOPLEVEL); gtk_window_set_default_size (GTK_WINDOW (win), 200, 200); align = gtk_alignment_new (0.5, 0.5, 0, 0); gtk_container_add (GTK_CONTAINER (win), align); gtk_widget_show (align); hbox = gtk_hbox_new (FALSE, 2); gtk_container_add (GTK_CONTAINER (align), hbox); gtk_widget_show (hbox); but = gtk_button_new_from_stock (GTK_STOCK_OPEN); gtk_box_pack_start (GTK_BOX (hbox), but, FALSE, FALSE, 2); g_signal_connect (but, "clicked", G_CALLBACK (on_open_clicked), win); g_timeout_add (100, (GSourceFunc) on_open_timeout, win); gtk_widget_show (but); but = gtk_button_new_from_stock (GTK_STOCK_CLOSE); gtk_box_pack_start (GTK_BOX (hbox), but, FALSE, FALSE, 2); g_signal_connect (but, "clicked", G_CALLBACK (on_close_clicked), win); gtk_widget_show (but); return win; } int main (int argc, char *argv[]) { GtkWidget *window1; gtk_init (&argc, &argv); window1 = create_window1 (); gtk_widget_show (window1); g_signal_connect (window1, "destroy", G_CALLBACK (gtk_main_quit), NULL); gtk_main (); return 0; }
_______________________________________________ gtk-list mailing list gtk-list@xxxxxxxxx http://mail.gnome.org/mailman/listinfo/gtk-list