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

memory leak in gtk



Hi,

I have made a simple application with a top level window:

"
#include <gtk/gtk.h>
#include <mcheck.h>

gboolean OnDeleteHandler(GtkWidget *sender,
                         GdkEvent  *event,
                         gpointer   data)
{
	return FALSE;
}

void OnDestroyHandler(GtkWidget *sender, gpointer data)
{
	gtk_main_quit();
}


int main(int argc, char *argv[])
{
mtrace();

	gtk_init(&argc, &argv);

	GtkWidget *mainWindow = gtk_window_new(GTK_WINDOW_TOPLEVEL);

	g_signal_connect(G_OBJECT(mainWindow), "delete_event",
		G_CALLBACK(OnDeleteHandler), NULL);
	g_signal_connect(G_OBJECT(mainWindow), "destroy",
		G_CALLBACK(OnDestroyHandler), NULL);

	gtk_widget_show_all(mainWindow);

	gtk_main();

//	gtk_exit(0);
//	exit(0);	

  return EXIT_SUCCESS;
}
"
I have used mtrace to check for memory leaks. In this simple
application there are more than 5000 memory allocation which is not
freed.

I have checked the GTK documentation and it states that gtk_exit free
all resources allocated for GTK+. gtk_exit is depricated and using
exit is recommended. I have tested both but non of them improved the
situation (still more than 5000 leaks).

Please could you help if I missed some cleanup in my application or
what is happening?

Thanks,
Csaba


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