leak in widget new/destroy
- From: Stephane Chauveau <s chauveau chello nl>
- To: gtk-devel-list gnome org
- Subject: leak in widget new/destroy
- Date: Sun, 03 Nov 2002 19:43:59 +0100
Hello,
I was looking for memory leaks in my program and I found that memory
seems to be
leaked after allocating and destroying widgets such as GtkButton and
GtkMenu
with Gtk 2.1.0
The example program below, allocates and frees a large number of
GtkButton.
It shows that around 80 bytes are leaked by each new/destroy.
In fact, gtk_widget_destroy does not seem to free anything.
Am I missing something?
PS: The 'cat /proc/<pid>/statm' is just a quick & dirty trick to
display the
memory usage on linux.
============================
#include <gtk/gtk.h>
#include <sys/types.h>
#include <unistd.h>
#include <stdio.h>
int
main (int argc, char *argv[])
{
GtkWidget *w;
int cpt=0 ;
gtk_init (&argc, &argv);
while(1) {
if (cpt%10000==0) {
/* easy way to print memory information */
char buf[1000] ;
printf("%d\n",cpt) ;
sprintf(buf,"cat /proc/%d/statm",getpid());
system(buf);
}
w = gtk_button_new() ;
gtk_widget_destroy(w) ;
cpt++ ;
}
return 0;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]