[Gtk-sharp-list] widget destruction

"Andrés G. Aragoneses" knocte at gmail.com
Mon Mar 7 11:32:22 EST 2011


This brings up again the debate: should GTK# change the API in the 3.x 
release to make Dispose() methods call Destroy() now that Gtk+3 broke 
API anyway?


On 07/03/11 08:15, huseyin cakir wrote:
> *Hi, we have memory problems in using gtk# in mono 2.8 so we started to
> use a method that includes dispose-destory of all objects.
>
> I mean we use one window widget and change fixed widget in it to use
> memory effectively and dispose destroy all widgets inside it(for example
> button widget).
>
> but it still increases memory usage in time.
>
> _Are there any other usages for less memory usage? Thank you._
> *
> *for example:*
>
> to navigate between two pages without memory consumption we use a method
> like below:
>
> fixed A fixed B
> ---------------------------
> window A
>
> add fixed A in window A with other widgets like button widget
>
> remove fixed a
>
> dispose destroy  fixed A with its children
>
> and add fixed B
>
> *-----------------------------------------------------------------------------------
> Page 1:*
>
> using System;
> using Gtk;
>
> namespace test
> {
>      class  Page1 : Fixed
>      {
>
>          Button btn1;
>          Image img1;
>          Gdk.Pixbuf px1;
>
>
>          public  Page1()
>          {
>
>              btn1=new Button("go Page2");
>              px1=new Gdk.Pixbuf("4991.gif");
>              img1=new Image(px1);
>              btn1.Clicked+= new EventHandler(btn1_Clicked);
>              this.Put(btn1,10,10);
>              this.Put(img1,10,50);
>
>
>          }
>
>          void btn1_Clicked(object sender, EventArgs e)
>          {
>              freeItems();
>              Page2 pg2=new Page2();
>              Test.win.Add(pg2);
>              Test.win.ShowAll();
>
>          }
>
>
>          void freeItems()
>          {
>              px1.Dispose();
>              img1.Dispose();
>              img1.Destroy();
>              btn1.Dispose();
>              btn1.Destroy();
>              Test.win.Remove(this);
>              this.Dispose();
>              this.Destroy();
>
>
>          }
>
>      }
> }
>
> *-----------------------------------------------------------------------------------
> Page 2:*
> using System;
> using Gtk;
>
> namespace test
> {
>
>      class  Page2 : Fixed
>      {
>
>          Button btn1;
>          Image img1;
>          Gdk.Pixbuf px1;
>
>          public  Page2()
>          {
>              btn1=new Button("go back page 1");
>              px1=new Gdk.Pixbuf("4991.gif");
>              img1=new Image(px1);
>
>              btn1.Clicked+= new EventHandler(btn1_Clicked);
>
>              this.Put(btn1,10,10);
>              this.Put(img1,10,50);
>
>          }
>
>          void btn1_Clicked(object sender, EventArgs e)
>          {
>              freeItems();
>              Page1 pg1=new Page1();
>              Test.win.Add(pg1);
>              Test.win.ShowAll();
>          }
>
>          void freeItems()
>          {
>              px1.Dispose();
>              img1.Dispose();
>              img1.Destroy();
>              btn1.Dispose();
>              btn1.Destroy();
>              Test.win.Remove(this);
>              this.Dispose();
>              this.Destroy();
>
>
>
> _______________________________________________
> Gtk-sharp-list maillist  -  Gtk-sharp-list at lists.ximian.com
> http://lists.ximian.com/mailman/listinfo/gtk-sharp-list




More information about the Gtk-sharp-list mailing list