From: Masao Mutoh Date: 2005-01-19T01:52:40+09:00 Subject: Re: [ruby-gtk2] Garbage collection and memory use Hi, On Tue, 18 Jan 2005 18:01:10 +0900 David Espada wrote: > Hi all. > > Look at next script: > When you push button, it triggers a loop that creates and destroy a > Gtk2 window in each iteration. For each 1000 iters, I call GC.start in > order to run Garbage Collection. > > In theory, there is no single variable that persist from one iter to > next, and garbage collection should reget memory for more use, without > collapsing physical memory and swap space. > > But that is what happens actually, and I don't know the reason. > What is problem with Garbage Collection? Why it doesn't free memory > althought I invoque it explicitly? Any clue or solution that doesn't > force me to change all code in order to reuse windows instead of > create them when I need? Try the code below: (gcc -o test `pkg-config gtk+-2.0 --libs --cflags` test.c) --- #include 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_object_destroy(GTK_OBJECT(window)); } gtk_main(); return 0; } --- You can notice it does not concern Ruby GC. I'm not sure but gtk_widget_show_all() causes this problem. > I am in the very edge, but it seems that Ruby Garbage Collection > doesn't work properly with Gtk2 widgets, because memory is not freed. Any solutions? P.S. I don't think it's not good idea to post these discussions here. If you want to discuss more, come ruby-gnome2 ML again.