Re: How to destory GtkWindow without memory leak



Hi Bob,

On Tue, 18 Jan 2005 16:14:22 -0600
Bob Caryl <bob fis-cal com> wrote:

I seem to be missing something here...   it appears that that your
while(TRUE) loop will never allow the gtk_main call to happen, hence you
are simply initializing, showing, and destroying the window widget ad
infinitum.  

This was an example for reproducing my problem.
Remove gtk_main() please. It doesn't concern the problem.
 
The call to gtk_widget_show_all is not necessary here, since there are
no children inserted into the window widget by your code.

I've noticed this problem isn't occured if I removed gtk_widget_show_all().

My issue was:

I want to free GtkWindow which is showed. But gtk_widget_destroy() seems
not to free allocated area completely. 

But I could solve it with the code below:

#include <gtk/gtk.h>

int main(int argc, char** argv){  
  GtkWidget* window;
  gtk_init(&argc, &argv);

  while(TRUE){
    window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
    gtk_widget_show_all(window);
    gtk_widget_destroy(window);
    while(gtk_events_pending()){
      gtk_main_iteration();
    }
  }
  return 0;
}

Thanks.

-- 
.:% Masao Mutoh<mutoh highway ne jp>



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